java为什么输出没有结果?

MyOnly 发布于 2013/01/02 15:36
阅读 695
收藏 0

interface Singer {
 public void sing();
 public void sleep();
}

interface Painter {
 public void paint();
 public void eat();
}

class Student implements Singer {
 private String name;
 Student(String name) {
  this.name = name;
 }
 public void study() {
  System.out.println("student is studying");
 }
 public String getName() {
  return name;
 }
 public void sing() {
  System.out.println("student is singing");
 }
 public void sleep() {
  System.out.println("student is sleeping");
 }
}

class Teacher implements Singer,Painter {
 private String name;
 Teacher(String name) {
  this.name = name;
 }
 public String getName() {
  return name;
 }
 public void teach() {
  System.out.println("teaching");
 }
 public void sing() {
  System.out.println("teacher is singing");
 }
 public void sleep() {
  System.out.println("teacher is sleeping");
 }
 public void paint() {
  System.out.println("teacher is painting");
 }
 public void eat() {
  System.out.println("teacher is eating");
 }
}

public class Test {
 public static void main(String[] args) {
  Student s = new Student("le");
  s.getName();
 }
}

 

加载中
0
书生_Maple
书生_Maple

只要添加一行代码:

public class Test {
 public static void main(String[] args) {
  Student s = new Student("le");
  System.out.println(s.getName());
  // s.getName();
 }
}

0
ddatsh
ddatsh
student  getName();里没sysout
sxgkwei
sxgkwei
小DD,这个你都能发现。。。
0
M
MyOnly
嗯,谢谢已解决
ddatsh
ddatsh
...
0
返回顶部
顶部