建立一个学生对象,输出学生信息

package ch07;

/**
 * Created by liwenj on 2017/7/19.
 */
public class Student {//创建一个对象
    String name;
    int age;
    String cla;
    String hobby;

    public void showmes() {//对象的一个方法
        System.out.println(name+" "+cla+" "+hobby);
    }


}

class student_person {
    public static void main(String[] args) {
        Student zhang = new Student();
        zhang.name = "张三";
        zhang.age = 24;
        zhang.cla = "2/3";
        zhang.hobby="弹琴";
        zhang.showmes();

        Student li = new Student();
        li.name = "李四";
        li.age = 24;
        li.cla = "2/3";
        li.hobby="口琴";
        li.showmes();
    }
}

 

posted @ 2017-07-19 14:40  斯丢皮德曼  阅读(313)  评论(0编辑  收藏  举报