forked from bhagat-hrishi/Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathanonymus.java
More file actions
26 lines (22 loc) · 648 Bytes
/
anonymus.java
File metadata and controls
26 lines (22 loc) · 648 Bytes
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
class anonymus
{
public static int sum(int[] x)
{
int total=0;
for(int x1:x)
{
total=total+x1;
}
return total;
}
public static void main(String [] args)
{
//decalaration
new int[]{10,20,30,40};//valid
new int[][]{{10,20},{30,40}};//valid
//At the time of anonymous array creation we can't specify the size otherwise we will get compile time error.
new int[3]{10,20,30,40};//C.E:';' expected(invalid)
//use of anonymus array
System.out.println(sum(new int[]{10,20,30,40}));//100
}
}