public String javaBlog(String blog){ return blog}

Photo by Tracy

It has marked just over a year since I’ve picked up a keyboard to transition into the magical world of software engineering and it’s been a humbling experience so far. This year, I’ve started a job with a company that uses Java which forces me to learn it.

Here is my biggest caveat with Java and I don’t know if I’m in the minority here for this but Java is so explicit. Unlike Javascript where you can define a variable and then initialize it to whatever datatype, java requires datatype initializing. Whats that mean? Take a look below.

let a = 6;

In my mind, it’s just too repetitive. I enjoyed that javascript new exactly what it would be after variable initialization and declaration. One other thing is that you cannot forget to use the semicolon in Java. It’s meant to define that you’ve moved on to a new line but it would be nice if it weren’t necessary. Many times I get an error because I’m just missing a semicolon.

One other thing I’ve noticed in Java is that method syntax is much more involved. Let’s take a look at those difference so that you can see what I’m talking about.

function addNumbers(num1, num2, num3){};

When creating a method inside of Java, you need to create an access modifier, the return type, and the name whereas in Javascript, you really just need to worry about the name. I’ve set two examples for Java, one using the void keyword and another using int.

The return type matters as you need to tell java wether the method should return something or not. In the first case (void), nothing needs to be returned but in the second case (int) an integer must be returned. Also notice how inside the parameters you need to include the datatype of each parameter.

Let’s talk numbers. It’s something I’m still getting use to but there are various types of datatypes for numbers all of which differ in terms of byte sizing. You have your int, double, short, long, float, and I’m sure I’m forgetting one or two. These differ in byte size and how they will be initialized. Also, you need to be aware of implicit type conversioning meaning int’s can become long can become float can become double but not the other way around unless mentioned explicitly. If you go from a larger type to smaller without explicit conversioning, you will get an error. What.a.headache.

// I know I Exaggerated values but this is to prove a point (to all you Java lovers)

Creating an array in Java is something I don’t know if I can get use to because if I do, I’ll forget that Javascript is so much more lenient on it. To create an array, there are a few way of doing it. You can initialize a new array or declare and initialize it.

long[] restaurantContacts = {1234567L, 12345678L, 1236789L};

You can also use the ‘new’ keyword with javascript but needing to explicitly mention the size and types that it expects to hold is pretty insane to me. AND they use curly braces for arrays which almost feels like I’m breaking an unspoken law in programming. I enjoy the free range that Javascript provides because I can make an array that looks like this [“Johnson”, 85, “Hello there”]. These restrictions are things I’ll need to get use to .

If it seems like I’m not a fan of it, I’m not but only time will tell. Thanks for reading!

Software Engineer based out of NYC. Learning more about programming everyday 👍

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store