注册 登录
编程论坛 JAVA论坛

为什么这里总是显示找不到符号

我有个梦想 发布于 2017-05-07 13:35, 1871 次点击
这是一个类
import java.util.Scanner;
public class Rectangle{
public void getsides(){
System.out.println("Please input the ares of the rectangle:");
Scanner input = new Scanner(System.in);
int areas = input.nextInt();
System.out.println("Now the sides of the rectangle is"+areas);
}
public void changeSize(){
System.out.println("Please input the sides you want to change;");
Scanner input2 = new Scanner(System.in);
int changeareas = input2.nextInt();
System.out.println("Now the sides of the rectangle is" + changeareas);
}
}
这是另一个类;
public class TestRectangle{
public static void main(String[] args){
TestRectangle test = new TestRectangle();
test.getsides();
test.changeSize();
}
}
这是编译结果
C:\Users\Administrator\Desktop>javac TestRectangle.java
TestRectangle.java:4: 错误: 找不到符号
test.getsides();
    ^
  符号:   方法 getsides()
  位置: 类型为TestRectangle的变量 test
TestRectangle.java:5: 错误: 找不到符号
test.changeSize();
    ^
  符号:   方法 changeSize()
  位置: 类型为TestRectangle的变量 test
2 个错误
是我在方法调用这里除了错误码还是我编码的代码哪里出了问题。求大神指引
2 回复
#2
凌风zx2017-05-08 09:27
TestRectangle这个类没有那些方法呀,当然找不到了
我猜你是想new Rectangle这个类吧

[此贴子已经被作者于2017-5-8 09:28编辑过]

#3
纵横阳仔2017-05-09 17:44
TestRectangle test = new TestRectangle();这里new错对象了
1