Skip to content

Commit cfc05b5

Browse files
added training demo codes
0 parents  commit cfc05b5

File tree

149 files changed

+2292
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

149 files changed

+2292
-0
lines changed

.idea/.gitignore

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/description.html

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/encodings.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/inspectionProfiles/Project_Default.xml

Lines changed: 24 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/libraries/mysql_connector_java_8_0_24.xml

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/project-template.xml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/uiDesigner.xml

Lines changed: 124 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
My name is Aditya Kshettri.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
My name is Aditya Kshettri.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package com.aditya.project.training;
2+
3+
public class Main {
4+
5+
public static void main(String[] args) {
6+
// write your code here
7+
}
8+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package com.aditya.project.training.day1.collections;
2+
3+
import java.util.ArrayList;
4+
import java.util.Iterator;
5+
import java.util.List;
6+
7+
public class ArrayListDemo {
8+
9+
public static void main(String[] args) {
10+
11+
List<Integer> data = new ArrayList<>();
12+
data.add(10);
13+
data.add(20);
14+
data.add(10);
15+
data.add(30);
16+
System.out.println("ArrayList size : " + data.size());
17+
System.out.println(data);
18+
data.add(0, 999);
19+
System.out.println("After adding at 0th index : " + data);
20+
data.remove(new Integer(20));
21+
System.out.println("After removing 20 by value : " + data);
22+
data.remove(2);
23+
System.out.println("After removing 10 by index 2 : " + data);
24+
25+
System.out.println("Using iterator :");
26+
Iterator<Integer> iterator = data.iterator();
27+
while (iterator.hasNext()) {
28+
Integer integer = iterator.next();
29+
System.out.println(integer);
30+
}
31+
32+
int sum = 0;
33+
iterator = data.iterator();
34+
while (iterator.hasNext()) {
35+
Integer integer = iterator.next();
36+
sum += integer;
37+
}
38+
System.out.println("Sum : " + sum);
39+
}
40+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.aditya.project.training.day1.collections;
2+
3+
import java.util.ArrayList;
4+
import java.util.List;
5+
6+
public class ArrayListEmployeeDemo {
7+
8+
public static void main(String[] args) {
9+
10+
List<Employee> employees = new ArrayList<>();
11+
employees.add(new Employee());
12+
employees.add(new Employee(1, "Aditya", 10000));
13+
employees.add(new Employee(2, "Adi", 10000));
14+
employees.add(new Employee(1, "Aditya", 10000));
15+
16+
System.out.println(employees);
17+
System.out.println(employees.size());
18+
19+
boolean removed = employees.remove(new Employee(1, "Aditya", 10000));
20+
System.out.println(removed);
21+
22+
System.out.println(employees);
23+
System.out.println(employees.size());
24+
}
25+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package com.aditya.project.training.day1.collections;
2+
3+
import java.util.Map;
4+
import java.util.concurrent.ConcurrentHashMap;
5+
6+
public class ConcurrentHashMapEmployeeDemo {
7+
8+
public static void main(String[] args) {
9+
10+
Map<String, Employee> employees = new ConcurrentHashMap<>();
11+
employees.put("a", new Employee());
12+
employees.put("b", new Employee(1, "Adi", 5000));
13+
employees.put("c", new Employee(2, "Aditya", 5000));
14+
15+
System.out.println(employees);
16+
System.out.println(employees.size());
17+
18+
employees.put("a", new Employee(3, "Ksh", 3000));
19+
20+
System.out.println("After overriding value for key 'a'");
21+
System.out.println(employees);
22+
System.out.println(employees.size());
23+
24+
System.out.println("--- USING ITERATOR ---");
25+
for (Map.Entry<String, Employee> entry : employees.entrySet()) {
26+
System.out.println(entry.getKey() + " : " + entry.getValue());
27+
}
28+
29+
System.out.println("--- KEYS ---");
30+
employees.keySet().forEach(System.out::println);
31+
32+
System.out.println("--- VALUES ---");
33+
employees.values().forEach(System.out::println);
34+
35+
System.out.println("--- KEY-VALUE ---");
36+
employees.forEach((key, value) -> System.out.println(key + " : " + value));
37+
38+
for (Map.Entry<String, Employee> entry : employees.entrySet()) {
39+
System.out.println(entry.getKey() + " : " + entry.getValue());
40+
// Both create & update possible here
41+
employees.put("a", new Employee(1, "Adi", 5000));
42+
employees.put("d", new Employee(1, "Adi", 5000));
43+
}
44+
}
45+
}

0 commit comments

Comments
 (0)