gpt4 book ai didi

java - 编译java代码错误

转载 作者:行者123 更新时间:2023-11-30 07:58:47 24 4
gpt4 key购买 nike

当我想编译名为 SetPoint.java 的文件时出现错误:

SetPoint.java:5: error: cannot find symbol
Point point = new Point();
^
symbol: class Point
location: class SetPoint
SetPoint.java:5: error: cannot find symbol
Point point = new Point();
^
symbol: class Point
location: class SetPoint
2 errors

我在名为 xyz 的文件夹中有这两个文件(Point.java 和 SetPoint.java)。我不知道我做错了什么。如果我在 IntelliJ 中做同样的事情,它就可以正常工作。

package xyz;

public class Point {
int coorX;
int coorY;
}

.

package xyz;

public class SetPoint {
public static void main(String args[]){
Point point = new Point();
point.coorX = 10;
point.coorY = 20;

System.out.println("Coordinate of point: ("+point.coorX+", "+point.coorY+")");
}

}

最佳答案

同时编译两个java文件,

javac *.java

javac SetPoint.java Point.java

关于java - 编译java代码错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40095917/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com