-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharray.java
More file actions
51 lines (33 loc) · 1.17 KB
/
Copy patharray.java
File metadata and controls
51 lines (33 loc) · 1.17 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/* here we re going to learn array in java
dfine array format
type [] arrayname = type [size ];
type = array type int , float etc
array name = koi bhi nam
new = keyword to make space in memory
type = same as above
size = size of array\\
////// ------- example int[]marks=newint[3];-------- ///////////////
*/
import java.util.*;
public class array{
public static void main(String args[]){
// define array
int[] marks = new int [5];
marks[0]= 88;
marks[1]= 88;
marks[2]= 88;
marks[3]= 88;
marks[4]= 88;
/*System.out.println(marks[0]);
System.out.println(marks[1]); /* here it take more spae in memory to store and more time to execute */
/* System.out.println(marks[2]);
System.out.println(marks[3]);
System.out.println(marks[4]); */
//// so we make loops here to avoid this
for(int i = 0; i<5 ; i++){
System.out.println(marks[i]);
}
}
}
// another way to declare the elemnt in array but less amount of array
// int[]marks = {1,2,3,4,5,6,7,8,9,0};