类 是一组相关属性和行为的集合
对象 是该事物的具体体现
1 class Dem1_Student{ 2 public static void main(String[] args) { 3 Student s = new Student(); 4 s.name = "张三"; 5 s.age = 23; 6 System.out.println(s.name+s.age); 7 s.sleep(); 8 } 9 }// 测试类 10 11 class Student{ 12 13 String name; 14 int age; 15 String gender; 16 17 public void study(){ 18 System.out.println("study....s"); 19 } 20 21 public void sleep(){ 22 System.out.println("sleep...."); 23 } 24 25 26 27 } //基本类
原文:http://www.cnblogs.com/panw3i/p/6347881.html