Presentation is loading. Please wait.

Presentation is loading. Please wait.

Java Arrays By Srinivas Reddy.S www.java9s.com. Arrays Collection of similar data types Stages Declaration Construction Initialization www.java9s.com.

Similar presentations


Presentation on theme: "Java Arrays By Srinivas Reddy.S www.java9s.com. Arrays Collection of similar data types Stages Declaration Construction Initialization www.java9s.com."— Presentation transcript:

1 Java Arrays By Srinivas Reddy.S www.java9s.com

2 Arrays Collection of similar data types Stages Declaration Construction Initialization www.java9s.com

3 Declaration Declaring Arrays: int[] marks; byte[] age; Less readable: int marks[]; byte age[]; www.java9s.com

4 Construction int[] marks; marks = new int[5]; “The size of the array is mandatory” In single line: int[] marks = new int[5]; marks www.java9s.com

5 Initialization Initialization is loading the array with the values. int[] marks = new int[5]; marks[0] =20; marks[1]=49; marks[2] =30; marks[3] = 67; marks[4] = 35; 01243 2049306735 www.java9s.com

6 Initialization – Objects class Pen{ } Pen[] pens = new Pen[3]; pens[0] = new Pen(); Pens[1] = new Pen(); Pens[2] = new Pen(); 012 www.java9s.com

7 Array Initializer. int[] marks ={20,39,40,30}; Array Initializer www.java9s.com

8 Two dimensional Array int[][] marks = new int[2][3]; marks[0][0] = 30; marks[0][1]=31; marks[0][2]=32; marks[1][0]=40; marks[1][1]=41; marks[1][2]=42; 0 1 0 1 0 122 30 314041 32 42 www.java9s.com

9 Two dimension- non uniform int[][] marks = new int[2]; marks[0] = new int[3]; marks[1] = new int[4]; 0 1 0 12 0123 www.java9s.com

10 Multidimensional Arrays int[][][] marks = new int[2][3][2]; 0 1 0 12 0 12 01 010101 0101

11 www.JAVA9S.com


Download ppt "Java Arrays By Srinivas Reddy.S www.java9s.com. Arrays Collection of similar data types Stages Declaration Construction Initialization www.java9s.com."

Similar presentations


Ads by Google