本文共 659 字,大约阅读时间需要 2 分钟。
定义一个teacher类,包括名字,年龄,学历,职位与自我介绍的方法
代码如下
package teacher;public class teacher { public String name; public int age; public String edcation; public String position; public teacher(String name, int age, String edcation, String position) { this.age = age; this.name =name; this.edcation =edcation; this.position=position; } public String introduction() { return "大家好!,我是"+name+",我今年"+age+"岁了,我的学历是"+edcation+",我的职位是"+position; } static class test { public static void main(String[] args) { teacher th =new teacher ("李华",41,"本科",""); System.out.println(th.introduction()); } }}
转载地址:http://quqzi.baihongyu.com/