* It shows that the page is updated without any action of users or refresh.
see here
Thursday, 15 November 2007
Thursday, 8 November 2007
Tuesday, 6 November 2007
Map example
import java.util.*;
public class HashMapTest
{
public static void main(String argv[])
{
HashMap hm = new HashMap();
System.out.println(hm.put("aaa", "111"));
System.out.println(hm.put("bbb", "222"));
System.out.println(hm.put("aaa", "444"));
System.out.println(hm.put("ccc", "333"));
System.out.println(hm.put("ccc", null));
System.out.println("HashMap size : " + hm.size());
Set set = hm.keySet();
Object []hmKeys = set.toArray();
for(int i = 0; i < hmKeys.length; i++)
{
String key = (String)hmKeys[i];
System.out.print(key);
System.out.print(" - ");
System.out.println((String)hm.get(key));
}
}
}
/**
run:java HashMapTest
output:
null
null
111
null
333
HashMap size : 3
ccc - null
bbb - 222
aaa - 444
public class HashMapTest
{
public static void main(String argv[])
{
HashMap hm = new HashMap();
System.out.println(hm.put("aaa", "111"));
System.out.println(hm.put("bbb", "222"));
System.out.println(hm.put("aaa", "444"));
System.out.println(hm.put("ccc", "333"));
System.out.println(hm.put("ccc", null));
System.out.println("HashMap size : " + hm.size());
Set set = hm.keySet();
Object []hmKeys = set.toArray();
for(int i = 0; i < hmKeys.length; i++)
{
String key = (String)hmKeys[i];
System.out.print(key);
System.out.print(" - ");
System.out.println((String)hm.get(key));
}
}
}
/**
run:java HashMapTest
output:
null
null
111
null
333
HashMap size : 3
ccc - null
bbb - 222
aaa - 444
Monday, 5 November 2007
List example
import java.util.List ;
import java.util.Vector ;
public class A {
public static void main(String[] args) {
A a = new A() ;
List b = a.getSchools() ;
// get values
for( int i = 0 ; i < b.size() ; i++ ){
String str = (String)b.get(i) ;
System.out.println("["+i+"]:"+str) ;
}
System.out.println("=================================") ;
// add the value as the last position
b.add("SchoolName4") ;
b.add("SchoolName5") ;
// get values
for( int i = 0 ; i < b.size() ; i++ ){
String str = (String)b.get(i) ;
System.out.println("["+i+"]:"+str) ;
}
System.out.println("=================================") ;
// insert value to 3 position
b.add(2, "SchoolName6") ;
// get values
for( int i = 0 ; i < b.size() ; i++ ){
String str = (String)b.get(i) ;
System.out.println("["+i+"]:"+str) ;
}
}
private List getSchools() {
Vector v = new Vector() ;
v.add("SchoolName1") ;
v.add("SchoolName2") ;
v.add("SchoolName3") ;
return (List)v ;
}
}
import java.util.Vector ;
public class A {
public static void main(String[] args) {
A a = new A() ;
List b = a.getSchools() ;
// get values
for( int i = 0 ; i < b.size() ; i++ ){
String str = (String)b.get(i) ;
System.out.println("["+i+"]:"+str) ;
}
System.out.println("=================================") ;
// add the value as the last position
b.add("SchoolName4") ;
b.add("SchoolName5") ;
// get values
for( int i = 0 ; i < b.size() ; i++ ){
String str = (String)b.get(i) ;
System.out.println("["+i+"]:"+str) ;
}
System.out.println("=================================") ;
// insert value to 3 position
b.add(2, "SchoolName6") ;
// get values
for( int i = 0 ; i < b.size() ; i++ ){
String str = (String)b.get(i) ;
System.out.println("["+i+"]:"+str) ;
}
}
private List getSchools() {
Vector v = new Vector() ;
v.add("SchoolName1") ;
v.add("SchoolName2") ;
v.add("SchoolName3") ;
return (List)v ;
}
}
Subscribe to:
Posts (Atom)