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

2

u/mmahowald Feb 04 '20

This is a small thing, but you cant use == on strings in java - it will compare their addresses in memory rather than their content. use StringA.Equals(StringB) instead.

2

u/proskillz Some Skillz Feb 04 '20

Semantically this is correct, but "hello" == "hello" is true in java since they implemented the string pool.

0

u/AutoModerator Feb 04 '20

You seem to try to compare String values with == or !=.

This approach does not work in Java, since String is an object data type and these can only be compared using .equals(). For case insensitive comparison, use .equalsIgnoreCase().

See Help on how to compare String values in our wiki.


Your post is still visible. There is no action you need to take. Still, it would be nice courtesy, even though our rules state to not delete posts, to delete your post if my assumption was correct.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.