The Difference Between Java and Javascript Arrays

The Internet is flooded with statements like Java and Javascript are similar as car and carpet.
But it does not hold true anymore…
No, they are like Ronaldo & Ronaldinho… They compete but in a sweet way. They are brothers and complements each other’s cons.

Let’s Get Started And See How Do They Do It Differently

1 # Creating An Empty Array

let jsArray = []; // Sweet ... easy ... it works
int[] javaArray = new int[]; 
// Compilation Error : Array Initializer Expected

The reason for the above error with java arrays is that by nature Arrays in Java are fixed in length. So we must pass the length of an array while creating it.
But with JavaScript arrays are dynamic in nature, they grows as we put new elements to it. ( Don’t worry java gives us ArrayList to address this issue )

// Right way to create an empty Java Array
int[] javaArray = new int[10]; // By passing the array length