Notes About Java - Possibly Part One

Time to learn again

I used Java about a two decades ago in a class about data structures and algorithms. At the time, the code came to mind easily and my sense was that, given access to documentation, Java pretty much writes itself. It can be verbose. With such an emphasis on objects and passing by value, referencing everthing can get very wordy. I am learning Java now, not just using it for a class, so I am writing down some thoughts in hopes they help me cement what I am learning.

The Java passes everything by value section is wrong

Java passes data types like int or double by value. But Objects are passed by reference. There are a couple observations I made in part one and part two that were based on my lack of knowledge. I’ll strike through those parts. If the thoughts have any value knowing that passing by reference is occurring, I’ll update my opinion.

Java passes everything by value

- It goes against the philosophy of the language to try and pass by reference. - javac (the bytecode compiler) checks will block many attempts to mimic passing by reference. - A frustrating example is final String[] or any array object declared with the final keyword. - The array iteslf cannot be modified. But the members of the Array can. - I have not found a good method of creating a simple array with static members. - There are object oriented methods of simulating this, but that protects immutability with code that can be modified rather than compile or run time immutability. - If Java could pass by reference then final variables could be added to arrays. - But this is not how things are done. If I want to do this, my time is better spent using a language with pointers.

Java is forgiving with its compile time error checking

The final keyword is scope specific

The Object versions of the data type primitives no longer use constructors

Literal doubles and floats need a D or F after them and longs need an L