1)
/**
* @file Outer.java
*/
package fox.math.kmust;
public class Outer {
public class Inner {
public void out(){
a="Inner";
output();
}
}
private String a = "Outer";
public void output() {
System.out.println(a);
}
public static void main(String[] args){
Inner inner=(new Outer()).new Inner();
inner.out();
}
}
2)
/**
* @file Animal.java
*/
package fox.math.kmust;
public interface Animal {
public void eat();
}
/**
* @file Zoo.java
*/
package fox.math.kmust;
public class Zoo {
public Animal getAnimal() {
return new Animal() {
@Override
public void eat() {
System.out.println(this.getClass().getName() + ":eat");
}
};
}
public void eat(Animal animal) {
animal.eat();
}
public static void main(String[] args) {
Zoo zoo = new Zoo();
Animal animal = zoo.getAnimal();
animal.eat();
zoo.eat(animal);
}
}
3)
/**
* @file Month.java
*/
package fox.math.kmust;
public enum Month {
JANUARY, FEBRUARY, MARCH, APRIL, MAY, JUNE, JULY, AUGUST, SEPTEMBER, OCTOBER, NOVEMBER, DECEMBER;
}
/**
* @file Months.java
*/
package fox.math.kmust;
public class Months {
public static void main(String[] args) {
Month month = Month.APRIL;
System.out.println("English Name:"+month.name());
System.out.println("Chinese Name:"+getChinese(month));
}
private static String[] chinese = { "一月", "二月", "三月", "四月", "五月", "优月",
"七月", "八月", "九月", "十月", "十一月", "十二月" };
private static String getChinese(Month month) {
return chinese[month.ordinal()];
}
}
6.实验数据和实验结果(用屏幕图形表示,可另加附页):
1)
Inner
2)
fox.math.kmust.Zoo$1:eat
fox.math.kmust.Zoo$1:eat
3)
English Name:APRIL
Chinese Name:四月
7.改进建议:
评分标准 学 风--报告格式规范,文字清晰 观察能力--正确描述和理解需要操作的问题
操作能力--正确输入程序,熟悉编程环境 调试能力--熟练使用调试功能解决程序错误