-
Notifications
You must be signed in to change notification settings - Fork 0
/
day3.java
85 lines (67 loc) · 2.34 KB
/
day3.java
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
77
78
79
80
81
82
83
84
85
import java.util.*;
public class day3 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
// int a[] = new int[5];
// for (int i = 0; i < a.length; i++ ) {
// // System.out.println(a[i]); // print the address of a[0]
// System.out.println("Enter value for the array: ");
// a[i] = sc.nextInt();
// System.out.println(a[i+1]);
// }
// for (int i : a) {
// System.out.println(i);
// }
// int[] a[] = {{1,2,3},{4,5,6},{7,8,9}};
// for (int i = 0; i < a.length; i++) {
// for (int j = 0; j < a.length; j++) {
// System.out.print(a[i][j]+" ");
// }
// System.out.println();
// }
// 1 2 1 3 6 [1][3]
// 1 2 3 2 4 [1][2]
// 1 5 [1][2]
// // jagged array
// int ar[][] = new int[3][];
// ar[0] = new int[2];
// ar[1] = new int[3];
// ar[2] = new int[1];
// int count = 0;
// for (int i = 0; i < ar.length; i++) {
// for (int j = 0; j < ar[i].length; j++) {
// ar[i][j] = count++;
// }
// }
// for (int i = 0; i < ar.length; i++) {
// for (int j = 0; j < ar[i].length; j++) {
// System.out.print(ar[i][j]+ " " );
// }
// System.out.println();
// }
// //COPY ACTIVITY
// char[] source = {'a','b','c','d'};
// char[] destination = new char[3];
// System.arraycopy(source, 0, destination, 0, 2);
// System.out.println(String.valueOf(destination));
ArrayList<Integer> nums = new ArrayList<>();
// int count = 1;
// for (; count < 6; count++) {
// nums.add(count);
// }
// nums.add(0);
// System.out.println(nums);
// nums.add(count);
// System.out.println(nums);
// nums.set(5, 7);
// System.out.println(nums);
// nums.remove(5);
// System.out.println(nums);
// nums.set(5, 7);
// for (int i = 0; i < nums.size(); i++) {
// System.out.println(nums.get(i));
// }
// Collections.sort(nums);
// System.out.println(nums);
}
}