How to define initialize and use short arrays in Java

1 Answer

0 votes
package javaapplication1;

public class JavaApplication1 {

    public static void main(String[] args) {

        short[] shortArr = new short[]{2, 13, 97, 101, 321, 78};
   
        System.out.println(shortArr[0]);
        System.out.println(shortArr[1]);
        
        System.out.println();
        for (int i = 0; i < shortArr.length; i++)
             System.out.println(shortArr[i]);
   
  }
}
  
/*
run:

2
13

2
13
97
101
321
78

*/

 



answered Sep 24, 2016 by avibootz

Related questions

1 answer 213 views
1 answer 201 views
1 answer 186 views
1 answer 182 views
1 answer 202 views
1 answer 208 views
1 answer 182 views
...