Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
33 lines (28 loc) · 1.29 KB

File metadata and controls

33 lines (28 loc) · 1.29 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
class array2
{
public static void main(String[] args)
{
//at time of creation each element is intitialized with default value
int [] a=new int[4];
boolean []b=new boolean[2];
for(int tmp:a)
System.out.println(tmp);
System.out.println("-------------------------------------------------------");
for(boolean tmp:b)
System.out.println(tmp);
System.out.println("-------------------------------------------------------");
//Whenever we are trying to print any object reference internally toString() method
float [][] f=new float[3][2];
System.out.println(a);
System.out.println(f);
System.out.println(f[0]);
System.out.println(f[0][0]);
System.out.println("-------------------------------------------------------");
//length is final variable applicable for array which give size of array and length() method is used for String
int [] x=new int[3];
System.out.println("length: "+x.length);//3
//In multidimensional arrays length variable represents only base size but not total size. <----------------------------------------------
int[][] tmp=new int[6][3];
System.out.println(tmp.length);//6
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.