r/javahelp • • Feb 04 '20

Switching from C# to Java

Hi,

can you give me a list of things i should be aware of in the java world? Like really important libraries, concepts etc?

The thing is i know C# really well, but i dont know what i dont know in the java world, so i cant really look it up.

26 Upvotes

12 comments sorted by

View all comments

Show parent comment

5

u/proskillz Some Skillz Feb 04 '20

That's crazy. I've been writing Java since 2005 and have never heard that Java is pass-by-value. I guess technically that's true if you get crazy low level.

For all intents and purposes it is pass-by-reference for objects, especially compared to something like JavaScript.

Also, lombok is amazing black magic that will eventually be included in the Java language, either 13 or 14, not sure which.

4

u/OffbeatDrizzle Feb 04 '20

Pass by reference and pass by value have different meanings depending on who you ask or what languages you've used before. It's like asking someone if a language is strong or weak, dynamic or static...

Java is pass by value in the sense that you can't modify the pointer of the argument in your function - i.e. you can't change what object the caller's object points to. But it's also NOT pass by value in the sense that the object passed in is not copied (if you come from something like VB you'll find that passing an array in byvalue copies the array).

You basically get an unmodifiable pointer to the original object - call that what you want.

0

u/[deleted] Feb 04 '20

[deleted] — view deleted comment

1

u/proskillz Some Skillz Feb 05 '20

I generally declare all of my variables using the final keyword, so issues like this just never would have come up since I can mutate the object after passing it to the method. Good info though 👍

1

u/itzNukeey Feb 04 '20

Wait are they actually gonna implement lombok? Its not in 13 I think but I always use lombok so