刚开始学习java,在一个教程中看到一个小程序就跟着敲了,但是怎么编译都出错

public class TypeTest{
private String eye="Black";
private int age=10;
public String setEye(){
return eye;
}
public void setEye(String e){
eye=e;
}
p

展开全部
收起
4回答
提交回答
  • 至过去的我

    2044人对此回答表示赞同

    我是未来的你,你现在是不是在年找寻小程序答案。你不要感觉诧异,给你来信原因,就是让你不在后悔。今天去学习如何推广小程序,相信......点击查看更多>
    发布于
  • 行云流水

    19人对此回答表示赞同

    你定义的变量是tt,结果你在后面打成了 t
    TypeTest tt=new TypeTest();

    -->System.out.println(t.getEye());
    你认真看看是不是这样
    函数名也错了
    展开
    19
    0回复
    发布于 5年前

    评论(0)

    收起评论

  • 白皓

    14人对此回答表示赞同

    你的TypeTest类中的getEye()方法打成了setEye(),把TypeTest类中
    public String setEye(){
    return eye;
    }
    改成
    public String getEye(){
    return eye;
    }
    就行了。
    还有你的Test类中,
    System.out.println(t.getEye());
    System.out.println(t.get
    展开
    14
    0回复
    发布于 5年前

    评论(0)

    收起评论

  • 末初之至

    6人对此回答表示赞同

    你的这个程序里面没有getEye方法.你调用肯定会报错的.
    1.将
    public String setEye(){
    return eye;
    }
    修改成
    public String getEye(){
    return eye;
    }
    2.将
    System.out.println(t.getEye());
    System.out.println(t.getAge());
    修改为:
    Sys
    展开
    6
    0回复
    发布于 5年前

    评论(0)

    收起评论

  • Taj

    1人对此回答表示赞同

    TypeTest tt=new TypeTest();
    tt.setEye("Blue");
    tt.setAge(20);
    TypeTest对象名为tt,而【System.out.println(t.getEye());】用的是t。

    改成tt.getEye()
    展开
    1
    0回复
    发布于 5年前

    评论(0)

    收起评论

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
咨询热线

13312967497

扫码添加业务即可随时咨询 还可领取小程序推广攻略

业务咨询: 13312967497
扫码咨询

扫码咨询套餐

回到顶部