1)设计一个程序,基于泛型Map实现10个英文单词的汉语翻译,即通过单词得到它的中文含义。
import java.util.*;
public class Ex22 {
public static void main(String[] args) {
String[] eng={“Apple”,”Orange”,”Green”};
String[] chs={“苹果“,”桔子“,”绿色“};
Map map=new HashMap();
for(int i=0;i<eng.length;i++)
map.put(eng[i],chs[i]);
String test=”Orange”;
System.out.println(test+”翻译:“+map.get(test));
}
}
2)
class HelloA {
public HelloA() {
System.out.println("HelloA");
}
{ System.out.println("I'm A class"); }
static { System.out.println("static A"); }
}
public class HelloB extends HelloA {
public HelloB() {
System.out.println("HelloB");
}
{ System.out.println("I'm B class"); }
static { System.out.println("static B"); }
public static void main(String[] args) {
new HelloB();
}
}