This is a preview

This playground version isn't public and is work in progress.

Java

Java

When C# was introduced in the early 2000s, it was accused of being "just an imitation of Java". (Java is 5 years older than C#.) The two languages diverged much more since that time, but the similarities are still quite obvious. Therefore, this section will be much shorter than the previous one.

Checking the sample code

Looking at the syntax

We can see similar features as in the C# sample solution, like:

  • classes, a static method as main, a strong and static type system, arrays, type casting, iterators, loops, conditionals, etc. The syntax is slightly different, but I will not go into detail for these features.

Some differences:

  • Java's String is immutable, so StringBuilder class is used to append characters to the solution character by character.
  • In C#, even the primitive types are objects. Java features wrapper classes for the same role. (e.g. Integer for int).
  • And, of course, there are many more differences, which are not visible from such a short sample code, and are beyond the scope of this short introductory article.

Other characteristics

  • Both Java and C# are 'managed' languages. Java compiles to Java bytecode, which is then run on a JVM (Java Virtual Machine). Lazter on, we will see some other languages relying on the same JVM.
  • By using JIT, their speeds fall in the same range.
  • Java is very popular in the enterprise application development, due to its "write once, run anywhere" philosophy.

Resources to check

Meme

Coming next...

After checking 2 compiled, managed languages with a strong type system, let's explore some languages with a very different approach: weakly typed and interpreted! We start by looking at PHP!

Open Source Your Knowledge: become a Contributor and help others learn. Create New Content