collection framework in java part-1


http://www.youtube.com/watch?v=ItuowP_WbQQ

About video:

Collection Framework contains 9 key interfaces.ArrayList class allows duplicates,null insertion possible,heterogeneous objects are allowed…collection framework in java interview questions
collection framework – list interface details
arraylist in java
arraylist in java tutorial
arraylist details (collection framework)
arraylist
arraylist vs linkedlist
arraylist in java with examples
arraylist implementation
arraylist class
arraylist class in java
difference between arraylist and linkedlist
difference between arrays and collections
difference between array and arraylist
difference between arraylist and vector
collection interview questions
collection interface in java
Java Collections Framework

string in java


public class StringDemoExample {
public static void main(String[] args) {
String s1 = “nag”;
String s2 = “nag”;
String s3 = s1;
String s4 = new String(“nag”);
String s5 = new String(“nag”);
System.out.println(s1 == s2);
System.out.println(s1 == s3);
System.out.println(s1.equals(s3));
System.out.println(s1 == s4);
System.out.println(s1.equals(s4));
System.out.println(s4 == s5);
System.out.println(s4.equals(s5));
}
}

What is the output of the about example?

how to sort hashmap in java


import java.util.HashMap;
import java.util.Map;
import java.util.TreeMap;

public class StringDemoExample {
public static void main(String[] args) {
Map<String, String> map = new HashMap<String, String>();
map.put(“9”, “EE”);
map.put(“8”, “DD”);
map.put(“7”, “CC”);
map.put(“6”, “BB”);
map.put(“5”, “AA”);
map.put(“4”, “bb”);
map.put(“3”, “dd”);
map.put(“2”, “aa”);
map.put(“1”, “cc”);
System.out.println(“Unsort HashMap values are …”);
printMap(map);
System.out.println(“Sorted HashMap…”);
Map<string, string=””> map1 = new TreeMap<string, string=””>(map);
printMap(map1);
}
private static void printMap(Map<string, string=””> map) {
for (Map.Entry entry : map.entrySet()) {
System.out.println(“Key : ” + entry.getKey() + ”   Value : “
+ entry.getValue());
}
}
}
OUTPUT:

Unsort HashMap values are …
Key : 3   Value :  dd
Key : 2   Value :  aa
Key : 1   Value :  cc
Key : 7   Value :  CC
Key : 6   Value :  BB
Key : 5   Value :  AA
Key : 4   Value :  bb
Key : 9   Value :  EE
Key : 8   Value :  DD
Sorted HashMap…
Key : 1   Value :  cc
Key : 2   Value :  aa
Key : 3   Value :  dd
Key : 4   Value :  bb
Key : 5   Value :  AA
Key : 6   Value :  BB
Key : 7   Value :  CC
Key : 8   Value :  DD
Key : 9   Value :  EE