I am a bit new to Java Programming. Two or three days ago, I encountered a Question regarding arrays in my mind which is give below.
Every Java Programmers knows, Array is a collection of Objects, it doesn't matter whether it contains primitive data types or Strings.
So my Question is, if Array is a collection of Objects so how does it treats or converts primitive data type into objects, because in Java, Primitive Data Type is different from Objects(like Strings). Consider the following program:-
int[] Array = new int[3];
Array[0] = 1;
Array[1] = 2;
Array[2] = 4;`
for(int a=0;a<Array.length;a++) System.out.println(Array[a]);
I made the Array or Array Object using new keyword and datatype follows it. This is, of course, workable for arrays. But when I do something like this for variable, it would get fail.
int var1 = new int 3;
For attention, asking again, how does in Java Array treats or converts the Primitive Data Type as Objects, since generally Primitive Data Types are not Objects.
Thank You!