- public class person {
- String name;
- int age;
- String sex;
- public void sleep()
- {
- System.out.println("Sleep[None]");
- }
- public void sleep(String place)
- {
- System.out.println(name + " on " + place + " are sleeping");
- }
- public void eat()
- {
- System.out.println("eat");
- }
- public String introduce()
- {
- String s;
- s="name:"+name+" age:"+age+" sex:"+sex;
- return s;
- }
- }
- public class test {
- public static void main(String[] args) {
- person p1=new person();
- p1.name="somebody";
- p1.age=12;
- p1.sex="man";
- p1.eat();
- p1.sleep("home");
- p1.sleep();
- System.out.println(p1.introduce());
- }
- }
如未特殊声明,文章均为原创。
本文标题:基本类的使用
本文链接:https://manwish.cn/article/%e5%9f%ba%e6%9c%ac%e7%b1%bb%e7%9a%84%e4%bd%bf%e7%94%a8.html
本文标题:基本类的使用
本文链接:https://manwish.cn/article/%e5%9f%ba%e6%9c%ac%e7%b1%bb%e7%9a%84%e4%bd%bf%e7%94%a8.html