Skip to content

Commit 7593278

Browse files
committed
update
1 parent c82aa9d commit 7593278

File tree

7 files changed

+217
-12
lines changed

7 files changed

+217
-12
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package kevinCollection;
2+
3+
import java.util.*;
4+
5+
public class CollectionsDemo {
6+
7+
public static void main(String[] args) {
8+
// ArrayList
9+
//exampleOne();
10+
}
11+
12+
public static void exampleOne() {
13+
// ArrayList
14+
List a1 = new ArrayList();
15+
a1.add("Zara");
16+
a1.add("Mahnaz");
17+
a1.add("Ayan");
18+
System.out.println(" ArrayList Elements");
19+
System.out.print("\t" + a1);
20+
21+
// LinkedList
22+
List l1 = new LinkedList();
23+
l1.add("Zara");
24+
l1.add("Mahnaz");
25+
l1.add("Ayan");
26+
System.out.println();
27+
System.out.println(" LinkedList Elements");
28+
System.out.print("\t" + l1);
29+
30+
// HashSet
31+
Set s1 = new HashSet();
32+
s1.add("Zara");
33+
s1.add("Mahnaz");
34+
s1.add("Ayan");
35+
36+
System.out.println();
37+
System.out.println(" Set Elements");
38+
System.out.print("\t" + s1);
39+
40+
// HashMap
41+
Map m1 = new HashMap();
42+
m1.put("Zara", "8");
43+
m1.put("Mahnaz", "31");
44+
m1.put("Ayan", "12");
45+
m1.put("Daisy", "14");
46+
System.out.println();
47+
System.out.println(" Map Elements");
48+
System.out.print("\t" + m1);
49+
}
50+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package kevinCollection;
2+
3+
import java.util.Map;
4+
import java.util.HashMap;
5+
6+
public class HashMapExample {
7+
8+
public static void main(String[] args) {
9+
Map m1 = new HashMap();
10+
m1.put("Zara", "8");
11+
m1.put("Mahnaz", "31");
12+
m1.put("Ayan", "12");
13+
m1.put("Daisy", "14");
14+
m1.put("gates", "70");
15+
16+
System.out.println();
17+
System.out.println(" Map Elements");
18+
System.out.print("\t" + m1);
19+
System.out.print("\t" + m1.get("gates"));
20+
}
21+
}

src/kevinCollection/ListExample.java

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package kevinCollection;
2+
3+
import java.util.*;
4+
5+
/**
6+
* An ordered collection (also known as a sequence). The user of this interface has precise control over where in the list each element is inserted. The user can access elements by their integer index (position in the list), and search for elements in the list.
7+
Set<E>:
8+
9+
A collection that contains no duplicate elements. More formally, sets contain no pair of elements e1 and e2 such that e1.equals(e2), and at most one null element. As implied by its name, this interface models the mathematical set abstraction.
10+
* @author kevingates
11+
*
12+
*/
13+
public class ListExample {
14+
15+
public static void main(String[] args) {
16+
// TODO Auto-generated method stub
17+
Example1();
18+
}
19+
20+
public static void Example1() {
21+
List a1 = new ArrayList();
22+
a1.add("one");
23+
a1.add("two");
24+
a1.add("three");
25+
a1.add(33);
26+
a1.add("two");
27+
a1.add("two");
28+
System.out.println(" ArrayList Elements");
29+
System.out.print("\t" + a1);
30+
31+
List l1 = new LinkedList();
32+
l1.add("Zara");
33+
l1.add("Mahnaz");
34+
l1.add("Ayan");
35+
System.out.println();
36+
System.out.println(" LinkedList Elements");
37+
System.out.print("\t" + l1);
38+
}
39+
40+
}

src/kevinCollection/SetExample.java

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package kevinCollection;
2+
//import java.util.*;
3+
4+
import java.util.Arrays;
5+
import java.util.HashSet;
6+
import java.util.*;
7+
8+
public class SetExample {
9+
10+
public static void main(String[] args) {
11+
// TODO Auto-generated method stub
12+
setString();
13+
}
14+
15+
public static void setInteger() {
16+
Set<Integer> a = new HashSet<Integer>();
17+
a.addAll(Arrays.asList(new Integer[] {1, 3, 2, 4, 8, 9, 0}));
18+
19+
Set<Integer> b = new HashSet<Integer>();
20+
b.addAll(Arrays.asList(new Integer[] {1, 3, 7, 5, 4, 0, 7, 5}));
21+
22+
// To find union
23+
Set<Integer> union = new HashSet<Integer>(a);
24+
union.addAll(b);
25+
System.out.print("Union of the two Set");
26+
System.out.println(union);
27+
28+
29+
}
30+
31+
public static void setString() {
32+
// TODO Auto-generated method stub
33+
Set<String> hash_Set = new HashSet<String>();
34+
hash_Set.add("Geeks");
35+
hash_Set.add("For");
36+
hash_Set.add("Geeks");
37+
hash_Set.add("Example");
38+
hash_Set.add("Set");
39+
System.out.print("Set output without the duplicates");
40+
41+
System.out.println(hash_Set);
42+
43+
// Set deonstration using TreeSet
44+
System.out.print("Sorted Set after passing into TreeSet");
45+
Set<String> tree_Set = new TreeSet<String>(hash_Set);
46+
System.out.println(tree_Set);
47+
}
48+
}

src/kevinCollection/SetExample1.java

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package kevinCollection;
2+
//import java.util.*;
3+
4+
import java.util.Arrays;
5+
import java.util.HashSet;
6+
import java.util.*;
7+
8+
public class SetExample1 {
9+
10+
public static void main(String[] args) {
11+
// TODO Auto-generated method stub
12+
setString();
13+
}
14+
15+
public static void setInteger() {
16+
Set<Integer> a = new HashSet<Integer>();
17+
a.addAll(Arrays.asList(new Integer[] {1, 3, 2, 4, 8, 9, 0}));
18+
19+
Set<Integer> b = new HashSet<Integer>();
20+
b.addAll(Arrays.asList(new Integer[] {1, 3, 7, 5, 4, 0, 7, 5}));
21+
22+
// To find union
23+
Set<Integer> union = new HashSet<Integer>(a);
24+
union.addAll(b);
25+
System.out.print("Union of the two Set");
26+
System.out.println(union);
27+
28+
}
29+
30+
public static void setString() {
31+
// TODO Auto-generated method stub
32+
Set<String> hash_Set = new HashSet<String>();
33+
hash_Set.add("one");
34+
hash_Set.add("two");
35+
hash_Set.add("three");
36+
hash_Set.add("four");
37+
hash_Set.add("four");
38+
System.out.print("Set output without the duplicates");
39+
System.out.println(hash_Set);
40+
41+
// Set deonstration using TreeSet
42+
System.out.print("Sorted Set after passing into TreeSet");
43+
Set<String> tree_Set = new TreeSet<String>(hash_Set);
44+
System.out.println(tree_Set);
45+
}
46+
}

src/kevinGates/GenericMethodTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ public static void main(String args[]) {
2525
System.out.println("\nArray characterArray contains:");
2626
printArray(charArray); // pass a Character array
2727
}
28-
}
28+
}

src/kevinGates/UserImplementInterface.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ public static void main(String[] args) {
1313
System.out.println("data="+user.data());
1414
}
1515

16-
// public void insert() {
17-
//
18-
// }
19-
//
20-
// public void update() {
21-
//
22-
// }
23-
//
24-
// public void delete() {
25-
//
26-
// }
16+
public void insert() {
17+
System.out.println("data=");
18+
}
19+
20+
public void update() {
21+
System.out.println("data=");
22+
}
23+
24+
public void delete() {
25+
System.out.println("data=");
26+
}
2727
}

0 commit comments

Comments
 (0)