简体   繁体   中英

Is {1,4,2} represented by a primitive Type in Java?

Do Numbers inside such brackets { } always belong to arrays or can it be a primitive Type too?

The exact task is: Decide for the following values (!) whether Java provides primitive data types for their representation. If yes, specify all matching ones.

I'm only not sure about this one: {1,4,2} There isn't any int [ ] infront of that, that's why i'm asking.

(sorry for the dumb question, very big noob here)

The code :

int[] array = {1,2,3};

Is equivalent to :

int[] array = new int[3];
array[0] = 1;
array[1] = 2;
array[2] = 3;

In java, arrays are objects (even if it's an array of primitive type)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM