Code Snippets in JAVA Programming and their OUTPUTS-COLLECTIONS
CODE SNIPPETS OUTPUT
COLLECTIONS
import java.
util.
*;
public class Test
{
public static void main(String args[])
{
ArrayList<String> stuff = new ArrayList<String>();
stuff.
add("Mumbai");...
More
Code Snippets in JAVA Programming and their OUTPUTS-COLLECTIONS
CODE SNIPPETS OUTPUT
COLLECTIONS
import java.
util.
*;
public class Test
{
public static void main(String args[])
{
ArrayList<String> stuff = new ArrayList<String>();
stuff.
add("Mumbai");
stuff.
add("Pune");
stuff.
add("Delhi");
stuff.
add("Bangalore");
System.
out.
println("unsorted" +stuff);
Collections.
sort(stuff);
System.
out.
println("sorted" +stuff);
}
}
unsorted[Mumbai, Pune,
Delhi, Bangalore]
sorted[Bangalore,
Delhi, Mumbai, Pune]
import java.
util.
Map;
import java.
util.
LinkedHashMap;
public class Test
{
public static void main(String[] a)
{
Map s = new LinkedHashMap();
s.
put("1", "one");
s.
put("3", "three");
s.
put("2", "two");
System.
out.
println(s.
toString());
{1=one, 3=three, 2=two}
Less