The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.
Java doesn't support multi-dimensional array in true sense. In a true two dimensional array, all the elements of array occupy a contiguous block of memory, but that's not true in Java. Instead, a multi-dimensional array is an array of array.
For example, two-dimensional array in Java is simply an array of a one-dimensional array
Fundamental. But never knew this. I'm not a Java developer though.
Interesting to see how the fundamental concepts get language/runtime specific.
Because generally speaking, you can normally access memory via it's address - and that means that to more to the "next" element you have to know the actual memory organisation. (Java doesn't have pointers, but this can be very important if you want to share data with other languages.)
And ... an array of 2 lines of 10,000 chars will occupy a lot less memory than an array of 10,000 lines of 2 chars ... plus, both will use more memory than a "true" 2D array of chars with the same number of elements.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
AntiTwitter: @DalekDave is now a follower!
Since I left C/C++, I have never accessed an array via its address. Actually, I never did before I started using C either (but using Pascal, CHILL and propritary Pascal-like languages ... not to talk of APL!). C/C++ is the only language where I ever was close to consider the memory address of an array.
In C/C++, you cannnot do much decent programming if you are not aware of the array name as a pointer.
E.g. in Pascal, if you declare an array summerMonths: array[may..agust] of travelPlans; then you wouldn't care if 'summerMonths' is the address of element 'may' and actual indexes reduced by four before multiplied by the element size to get the element offset, or 'summerMonths' is the element of the (non-existing) 'january' element so that actual indexes may be directly multiplied by the element size to get the element offset. I believe that the Pascal standard says nothing about the implementation, and the compiler could do it either way. At least in the "original" Pascal that wasn't made for linking with modules in other languages. Maybe some external interface specification defines which address (of a non-existing elment 0 or of the first existing element) is transferred, to make the C programmers comfortable
None of that affects the Pascal code, though. You address summerMonth[july] as one of four travelPlans objects, without knowing what its address is and how it was calculated. Why would you care? In C/C++ you more or less have to care.
When using C for writing machine code, e.g bottom layer drivers, where the task by definition relates to physical addresses, controlling the exact binary code emitted by the compiler, you of course have to know. Pascal wasn't meant for those kind of tasks. My guess is that well above 99% of all C/C++ code written is not at that low level either, and actual physical addresses are not relevant. Yet, because of that fraction of a percent, all C/C++ programmers must be aware of the array as a pointer, indexing as a kind of pointer arithmetic etc.
If I work at that bottom level, interfacing directly to harware, I appreciate C. For higher levels, user applications in particular, I prefer languages that does not give me the freedom of C, and that relieves me from knowing which addresses are generated by the compiler.
Java developers know this. They have to, because it works differently enough that you have to care. Also it means that something like an image is often presented as a 1D array (for example bitmap.getPixels dumps the pixels in an int that you supply) and you have to do the index conversion yourself.
Yup, and I dare say there are array and record class libraries that you can download and import, with built-in iterators for the java.util.Arrays functions, to save a bit of work if you have to do a bunch of them of different sizes and types.
If not, it'd be a nice hobby project for someone.
I wanna be a eunuchs developer! Pass me a bread knife!
Maybe because they knew of other languages than C/C++
On the serious side: Newly educated Masters of today know "nothing" about langugages that are not of "the C class". If you show them something like APL, they look upon it like something from a fantasy world, cannot fathom how you can solve a problem in such a language.
Or a little closer to the C class: If you show them that in Pascal, you need not enclose conditions in parentheses, you can test "if x > 5" like we would write it in ordinary prose text; they as surprised how you can know that it is a condition when it is not parenthesized. "The standard model" uses parentheses.
"The standard model" prescibes that array indexes run from zero, and are integers. You show them a Pascal array summerMonths: array[may..august], and they worry about element zero of the array, where is that in all of this.
"The standard model" says that characters and enums "really" are integers, noting else. So a language that doesn't let you divide 'B' by 2 to get an exclamation mark, or multiply february with 3 to get april, breaks with the standard model.
Show them CHILL where you need not pre-announce that there is an exception handler. But "the standard model" requires a "try" and enclosing the block in braces! How can you know the scope of the exception handler? The 'block' to which it is attached? But isn't that what the braces do, delimit the block, so how can you avoid the braces?
After working for a while with CHILL, I never understood this "try" fixation - it is just a wart caused by exception handling being a cludge added to C long after its "design".
In CHILL, any block (and contrary to C: A simple statement is a block) can have an exception handler; just add it before the terminating semicolon, whether the block is a simple assignment, a loop, a function body, or even an entire module. To satisfy "C language class" oriented guys, you could say that an ON clause at the end of the block "implies a try at the start of the block" - but there is never any need for an explicit "try" (so it doesn't exist in the language).
Furthermore, to reduce the red tape of exception handling, "ON" is like a C "switch": The exception codes are like labels, followed by a block for handling that exception (but as a simple statement is also a block, there is no red tape for simple, one-statement handing), with an ELSE option.
So to me, C style exception handling is kludgy and inflexible.
When you come home from work, or when your significant other comes home, how good are you, are they, at leaving all the work trials and tribulations at the doorstep and simply "being present" with your SO? I realize that "being present" means occasionally hearing about work, but how consuming is it? Do you agree on, say, 15 minutes of venting time? Or does work issues consume the entire evening, or not at all?
I might check my work email or otherwise login to my work computer from home outside of working hours once a month. Most of that has to do with deployments; I'm doing educational software and we can't deploy until kids are done on the system for the day. That's generally between 4:30 and 5 my time (stupid timezones to my west ); but occasionally is later and logging in around 7 or 10 for 5 minutes to kick off a deploy and make sure it goes as planned is less annoying than staying late on days I got in around 8 instead of 8:20.
Did you ever see history portrayed as an old man with a wise brow and pulseless heart, weighing all things in the balance of reason?
Is not rather the genius of history like an eternal, imploring maiden, full of fire, with a burning heart and flaming soul, humanly warm and humanly beautiful?
Training a telescope on one’s own belly button will only reveal lint. You like that? You go right on staring at it. I prefer looking at galaxies.
-- Sarah Hoyt
It's an unequal balance but I'm usually okay with it. My beloved is an elementary school teacher so I need to listen to her frustrations with people and policies (Sometimes makes me want to take a bat and "explain" things to those who are causing her stress) and her own imposter syndrome worries.
She doesn't understand nor cares about what I do so technical challenges are met with an "I don't care" but if there are interpersonal problems she does listen.
I've come to accept it after over 30 years of marriage.
Nowadays I'm pretty good with that - we do talk about things at work occasionally, but the pressure of the work does not came home with me (or her)...
It took some years to learn that however, but I was lucky and finished 'school' before wedding...
"The only place where Success comes before Work is in the dictionary." Vidal Sassoon, 1928 - 2012
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpful answers is nice, but saying thanks can be even nicer.