This关键字
来源:互联网 发布:半身裙淘宝店好一点 编辑:程序博客网 时间:2024/05/20 08:24
public class Students {//定义变量
String name;
String sex;
int age;
public Students(String name,String sex,int age){//通过this关键字来表示当前成员变量的引用
this.name=name;
this.sex=sex;
this.age=age;
}
void showInfo(){//定义方法,显示学生信息
System.out.println(“姓名”+name);
System.out.println(“性别”+sex);
System.out.println(“年龄”+age);
}
public static void main(String[] args) { // TODO 自动生成的方法存根 Students sc=new Students("李四","男",20);//初始化 System.out.println("学生信息"); sc.showInfo();//调用方法,输出sc的学生信息}
}
运行结果如下图所示
阅读全文
0 0
- 关键字this
- this关键字
- this关键字
- this 关键字
- this 关键字
- this关键字
- this关键字
- this 关键字
- this 关键字
- this 关键字
- this关键字
- 关键字this
- 关键字this
- this 关键字
- this 关键字
- this关键字
- this关键字
- This关键字
- 201711学习笔记
- IT男不得不看的影视剧---《数字追凶》
- 三角形的判定
- factory查看年龄
- 经典排序算法
- This关键字
- uva512 犹如艺术品般的代码
- Android 4.4.2 exfat 移植
- SSM框架中的分页操作
- 空间配置器简版
- 计蒜客 最长不重复子串
- angularJs中的http服务
- ssh-struts2知识点
- valgrind排查内存泄漏步骤