r/learnjava • • Jun 21 '21

Why learn Java when there's C#?

I am genuinely curious, as it seems C# has superseded Java in many regards. The only reason I can think of using Java is backward compatibility.

EDIT: To clarify, the main selling point of Java was cross-platform, but nowadays most frameworks and toolsets are to some degree cross-platform, including .NET Core, which is the new main framework of C#.

0 Upvotes

36 comments sorted by

View all comments

6

u/elky87 Jun 21 '21

The post you linked is really old. There they talk about Java 7 but the next release is already Java 17! So 10 Version ahead.

I guess the biggest selling point is cross platform independence, and the huge huge huge ecosystem. There is a library for everything

Edit: this comment should have been in response to OPs comment with the stackoverflow question

0

u/kres0345 Jun 21 '21

Sorry, didn't notice the date, but that diesn't change the fact that I used the language (does Android Studio use Java 16?) and the language is very verbose and, from my perspective, lacking in features.

1

u/elky87 Jun 21 '21

What feature do you miss? What is possible in C# but not possible in Java?

I have no experience in C# so I am curious

1

u/kres0345 Jun 21 '21

Of the top of my head, it's a nitpick, but enums can have values in C# and you can cast between the enum representation and the integer type defined.

There's also events/delegates, tbh I'm still not entirely sure of how event listeners works in Java, took me awhile to figure out the basics as I'm used to just 'subscribing' a method to an event listener by specifying the event, then literally using the addition operator to add the method. Something like this mouseClick += my_method. Though I will admit the way of doing it in Java with inheritance is really clever.

2

u/elky87 Jun 21 '21

In Java enums can also have values, and of course Java also has events/delegates just a different syntax.

So the two languages are really similar but Java just has the bigger ecosystem. And that’s why it is used.