-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArraysLecture.java
More file actions
77 lines (66 loc) · 2.35 KB
/
ArraysLecture.java
File metadata and controls
77 lines (66 loc) · 2.35 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import java.util.ArrayList;
import java.util.Scanner;
public class ArraysLecture {
static int[] inputArray(){
Scanner scanner = new Scanner(System.in);
System.out.println("Enter Size of Array");
int n = scanner.nextInt();
int[] intArray = new int[n];
for (int i = 0; i < n; i++) {
System.out.println("Enter "+i+" Element of Array");
intArray[i] = scanner.nextInt();
}
scanner.close();
return intArray;
}
static void outputArray(int[] intArray){
for (int i = 0; i < intArray.length; i++) {
System.out.println(intArray[i]);
}
}
public static void main(String[] args) {
// All are valid declarations -
int[] intArray = {10,20,30};
int[][] my2dArray = {
{10,20,30},
{40,50,60}
};
// outputArray(inputArray());
// System.out.println(intArray[0]);
// System.out.println(my2dArray[0][0]);
// for(int e : intArray){
// System.out.println(e);
// }
// System.out.println(intArray.length);
// for(int i=0;i<=intArray.length;i++){
// System.out.println(intArray[i]);
// }
// System.out.println("Hellow World");
// byte[] byteArray;
// short[] shortsArray;
// boolean[] booleanArray;
// long[] longArray;
// float[] floatArray;
// Float[] fl;
// int intArray[];
// byte byteArray[];
// short shortsArray[];
// boolean booleanArray[];
// long longArray[];
// float floatArray[];
// double doubleArray[];
// char charArray[];
// int[] intArray = new int[10];
// byte[] byteArray = new byte[10];
// short[] shortsArray = new short[10];
// boolean[] booleanArray = new boolean[10];
// long[] longArray = new long[10];
// float[] floatArray = new float[10];
ArrayList<String> al = new ArrayList<>();
al.add("shiv");
al.add("Coding");
al.add("Wallah");
al.add(0,"first");
System.out.println(al);
}
}