File tree Expand file tree Collapse file tree 8 files changed +129
-1
lines changed
Expand file tree Collapse file tree 8 files changed +129
-1
lines changed Original file line number Diff line number Diff line change 1+ import java .util .ArrayList ;
2+
3+ public class arrayList {
4+ public static void main (String [] args ) {
5+ ArrayList <String >students =new ArrayList <>();
6+ students .add ("Aman" );
7+ students .add ("Boat" );
8+ students .add ("Emcure" );
9+ students .add (1 ,"New Boat" );
10+ String c =students .get (2 );
11+ String d =students .set (2 ,"Hellewwss" );
12+ students .remove (2 );
13+ System .out .println (students .size ());
14+ System .out .println (c );
15+ System .out .println (d );
16+ System .out .println ( students .contains ("a" ));
17+ for (String a : students ){
18+ System .out .print (a +" " );
19+ }
20+ System .out .println ();
21+ System .out .println (students );
22+ }
23+ }
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change 1+ import java .util .HashMap ;
2+ import java .util .Map ;
3+
4+ public class hashMap {
5+ public static void main (String [] args ) {
6+ Map <String ,Integer >numbers =new HashMap <>();
7+ numbers .put ("One" ,1 );
8+ numbers .put ("Two" ,2 );
9+ numbers .put ("Three" ,3 );
10+ numbers .put ("Four" ,4 );
11+ System .out .println (numbers );
12+ System .out .println ("Entries: " );
13+ for (Map .Entry <String ,Integer >e :numbers .entrySet ()){
14+ System .out .print (e +" " );
15+ }
16+ System .out .println ();
17+
18+ System .out .println ("Keys: " );
19+ for (Map .Entry <String ,Integer >e :numbers .entrySet ()){
20+ System .out .print (e .getKey ()+" " );
21+ }
22+ System .out .println ();
23+ System .out .println ("Values: " );
24+ for (Map .Entry <String ,Integer >e :numbers .entrySet ()){
25+ System .out .print (e .getValue ()+" " );
26+ }
27+ }
28+ }
Original file line number Diff line number Diff line change 1+ import java .util .HashSet ;
2+ import java .util .LinkedHashSet ;
3+ import java .util .Set ;
4+ import java .util .TreeSet ;
5+
6+ public class hashSet {
7+ public static void main (String [] args ) {
8+
9+ Set <Integer >set =new HashSet <>();
10+ set .add (23 );
11+ set .add (1 );
12+ set .add (2 );
13+ set .add (5 );
14+ set .add (2 );
15+ set .remove (2 );
16+ System .out .println (set );
17+ System .out .println ( set .contains (1 ));
18+ System .out .println (set .size ());
19+ System .out .println ("*** *** *** *** *** *** *** *** *** ***" );
20+ Set <Integer >setl =new LinkedHashSet <>();
21+ setl .add (23 );
22+ setl .add (1 );
23+ setl .add (2 );
24+ setl .add (5 );
25+ setl .add (2 );
26+ setl .remove (2 );
27+ System .out .println (setl );
28+ System .out .println ( setl .contains (1 ));
29+ System .out .println (setl .size ());
30+ System .out .println ("*** *** *** *** *** *** *** *** *** ***" );
31+ Set <Integer >setree =new TreeSet <>();
32+ setree .add (23 );
33+ setree .add (1 );
34+ setree .add (2 );
35+ setree .add (5 );
36+ setree .add (2 );
37+ setree .remove (2 );
38+ System .out .println (setree );
39+ System .out .println ( setree .contains (1 ));
40+ System .out .println (setree .size ());
41+
42+ }
43+ }
Original file line number Diff line number Diff line change 1+ import java .util .ArrayDeque ;
2+
3+ public class arrayDeque {
4+ // pronounced as 'deck'
5+ public static void main (String [] args ) {
6+ ArrayDeque <Integer >adq =new ArrayDeque <>();
7+ adq .offer (3 );
8+ adq .offerFirst (13 );
9+ adq .offerLast (23 );
10+ System .out .println (adq );
11+
12+ adq .pollFirst ();
13+ adq .pollLast ();
14+ System .out .println (adq );
15+ }
16+ }
Original file line number Diff line number Diff line change 1+ import java .util .Comparator ;
2+ import java .util .PriorityQueue ;
3+
4+ public class priorityQueue {
5+
6+ public static void main (String [] args ) {
7+ PriorityQueue <Integer >pq =new PriorityQueue <>(Comparator .reverseOrder ());
8+ pq .offer (1 );
9+ pq .offer (31 );
10+ pq .offer (22 );
11+ pq .offer (5 );
12+ System .out .println (pq );
13+ System .out .println (pq .poll ());
14+ System .out .println (pq .peek ());
15+
16+
17+ }
18+ }
You can’t perform that action at this time.
0 commit comments