1 package day03; 2 3 public class class_lei { 4 5 public static void main(String[] args) { 6 // TODO Auto-generated method stub 7 Teacher t1=new Teacher(); 8 t1.name="tom"; 9 t1.age=23; 10 t1.address="昆仑山181号"; 11 t1.salary=456.25; 12 //String t1.color="red"; 13 t1.eat(); 14 t1.sleep(); 15 16 17 //Teacher t2=new Teacher(){name:"Jack",age:32,address:"天山路",salary:45.01}; 18 } 19 20 } 21 class Teacher{ 22 String name; 23 int age; 24 String address; 25 double salary; 26 27 void eat() { 28 System.out.println(name+"正在吃饭。。。,他家的地址是"+address); 29 } 30 void sleep() { 31 System.out.println("正在睡觉..."); 32 } 33 }