is object of array is created in memory when we create array like this int arr []={1,2,3}; | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

is object of array is created in memory when we create array like this int arr []={1,2,3};

as we know that object is created by help of new keyword in java so in case when create array like this....int arr []={1,2,3}; the object of array will be created or not???

11th Feb 2020, 7:40 PM
Wasiq Abdullah
3 Answers
0
//int[] arr = new int[] {1,2,3}; int[] arr = {1,2,3}; System.out.println( arr instanceof int[] ); // true System.out.println( arr instanceof Object ); // true System.out.println( arr.getClass() ); // class [I Object obj = (Object) arr; // ok
11th Feb 2020, 10:21 PM
zemiak
0
TheCoder | I Specialise in C# right bro but where it will create memory??i mean inside heap or emewhere else?? ...and how object would be created in heap in this case int arr []={1,2,3}; as we know that we fid not used new keyeord here
12th Feb 2020, 2:01 AM
Wasiq Abdullah
0
it is language simplification for some basic types to not use new keyword such as String s = "abc"; String st = new String("abc");
12th Feb 2020, 7:46 AM
zemiak