几道java基础题

1.public static void main(String[] args) {
String classPath = "java.lang.String";
System.out.println(classPath.replaceAll(".", "/"));
}

2.public static void main(String[] args) {
StringBuilder sb = new StringBuilder();
switch(1) {
case 1 : sb.append("Hello a");
case 2 : sb.append("b");
case 3 : sb.append("c");
default : sb.append("d");
}
System.out.println(sb.toString());
}

3.public class Increment {
public static void main(String[] args) {
int j = 0;
for (int i = 0; i < 100; i++)
j = j++;
System.out.println(j);
}
}

4.import java.util.*;

public class DatingGame {
public static void main(String[] args) {
Calendar cal = Calendar.getInstance();
cal.set(1999, 12, 31); // Year, Month, Day
System.out.print(cal.get(Calendar.YEAR) + " ");

Date d = cal.getTime();
System.out.println(d.getDay());
}
}
待续中...

你可能感兴趣的:(java)