package com.wuming.oop.demo02; //学生类 public class Student {//属性:字段String name;//nullint age=0;//0//方法public void study(){System.out.println(this.name+"在学习");} }
//在该类同包下在创一个类
package com.wuming.oop.demo02;public class Application {public static void main(String[] args) {//类:抽象的,实例化//类实例化后会返回一个自己的对象!//student对象就是一个Student类的具体实例Student xiaoming = new Student();Student xh = new Student();xiaoming.name="小明";xiaoming.age=3;System.out.println(xiaoming.name);System.out.println(xiaoming.age);xh.name="小红";xh.age=3;System.out.println(xh.name);System.out.println(xh.age);} }
小明
3
小红
3