Hello, I'm asking you a question because I'm stuck in an object declaration error while studying Java!
#Box.java
public class Box {
int width=0;
int height=0;
public void printSize()
{
System.out.println("Size: "+(width*height));
}
}
#BoxTest.java
public class BoxTest {
public static void main(String[] args) {
Box mybox = new Box();
mybox.width=30;
mybox.height=20;
mybox.printSize();
}
}
C:\java1> javac Box.java BoxTest.java
C:\java1> java BoxTest.java
If it is as stated in the book, it should be executed normally when this is done.
#Error
C:\java1> java BoxTest.java
BoxTest.java:3: error: cannot find symbol
Box mybox = new Box();
symbol: class Box
location: class BoxTest
BoxTest.java:3: error: cannot find symbol
Box mybox = new Box();
symbol: class Box
location: class BoxTest
2 errors
error: compilation failed
An error appears stating that the class box is incorrect
It is said that cannot find symbol is usually a typo problem, but I don't think it is.
I have a question
Any help would be appreciated!
java javac
java
The command runs a compiled class file or archive file.
java BoxTest
You must enter .
613 GDB gets version error when attempting to debug with the Presense SDK (IDE)
578 Understanding How to Configure Google API Key
618 Uncaught (inpromise) Error on Electron: An object could not be cloned
916 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
574 Who developed the "avformat-59.dll" that comes with FFmpeg?
© 2024 OneMinuteCode. All rights reserved.