package aa;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
//for test6
import static java.lang.Math.*;
public class Test {
public static void main(String[] args) {
// 1
Double d = 123.45;
d += 20.601;
System.out.println(d);
double dd = d + 45.123;
System.out.println(dd);
// 2,3
List<List<String>> list = new ArrayList<List<String>>();
List<String> line1 = new ArrayList<String>();
line1.add("hello");
line1.add(",");
line1.add("world");
// line1.add(new Integer(123));//complie error
list.add(line1);
List<String> line2 = new ArrayList<String>();
line2.add("hello2");
line2.add(",");
line2.add("world2");
list.add(line2);
for (List<String> g : list) {
for (String str : g) {
System.out.print(str);
}
System.out.println();
}
// 4
Color bg = Color.Red;
System.out.println(bg);
for (Color c : Color.values()) {
System.out.println(c);
}
// 5
print("hello", ",", "World", new Date(), 123456);
//6
double i=2*PI;
print(i);
}
public static void print(Object objects) {
for (Object obj : objects) {
System.out.println(obj);
}
}
}
enum Color {
Red, Green, Blue
}
posted on 2006-02-05 10:55
java小记 阅读(229)
评论(0) 编辑 收藏