zoukankan      html  css  js  c++  java
  • 类与对象的创建

    package com.oop.demo02;

    //一个项目应该只有一个main方法
    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);

    System.out.println(xh.name);
    System.out.println(xh.age);

    }
    package com.oop.demo02;

    //学生类
    public class Student {

    //属性:字段
    String name;//null
    int age;//0


    //方法
    public void study(){
    System.out.println(this.name+"在学习");
    }

    }
    //学程序好?对世界更好的建模!


    }
  • 相关阅读:
    生活感悟
    shell语法
    mycat
    阐述 如何高效理解学习
    部署ETCD集群
    文件修改
    文件处理
    a's
    shell中备份web站点及数据库
    openssh版本升级修复漏洞
  • 原文地址:https://www.cnblogs.com/yuanzhihui/p/14872564.html
Copyright © 2011-2022 走看看