What does the `new` keyword do

后端 未结 9 1881
情深已故
情深已故 2020-12-01 09:41

I\'m following a Java tutorial online, trying to learn the language, and it\'s bouncing between two semantics for using arrays.

long results[] = new long[3]         


        
9条回答
  •  独厮守ぢ
    2020-12-01 10:23

    The 'new' keyword creates an array. Now, depending on what type of data the array is for the values inside of it vary. If you declare the array as an integer and use the 'new' keyword then it will contain the values 0 unless you change the values inside. With a String it will contain the value 'null'. In every single space.

提交回复
热议问题