package study; //创建类 public class note { char color; int cpu; public void show() { System.out.println("笔记本的颜色是"+color+"笔记本的型号是"+cpu); } } package study; //测试类 public class test { public static void main(String[] args) { // TODO Auto-generated method stub note n=new note(); n.color='r'; n.cpu=3; n.show(); } }
package study; //创建类 public class person { String name; double height; double age; public void sayHello() { System.out.println("Hello,my name is "+name); } } package study; //测试类 public class PersonCreate { public static void main(String[] args) { // TODO Auto-generated method stub person p=new person(); p.name="zhangsan"; p.height=1.73; p.age=33; p.sayHello(); person w=new person(); w.name="lishi"; w.height=1.74; w.age=44; w.sayHello(); } }