-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
31 lines (28 loc) · 921 Bytes
/
Copy pathMain.java
File metadata and controls
31 lines (28 loc) · 921 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
27
28
29
30
31
//TIP To <b>Run</b> code, press <shortcut actionId="Run"/> or
// click the <icon src="AllIcons.Actions.Execute"/> icon in the gutter.
public class Main {
public static void main(String[] args) {
Main ArrayUtil = new Main(); //instance of main class
ArrayUtil.arrayDemo();//calling arrayDemo method
}
public static int arrayDemo(){
int[] myArray = new int[5];
myArray[0] = 5;
myArray[1] = 6 ;
myArray[2] = 8 ;
myArray[3] = 10 ;
myArray[4] = 9 ;
System.out.println(myArray);
System.out.println(myArray.length);
System.out.println(myArray[myArray.length-1]);
return 1 ;
}
public void printArray(int[] arr)
{
int n = arr.length;
for(int i=0 ;i<=n ; i++){
System.out.println(arr[i] + " ");
}
System.out.println();
}
}