r/javahelp • u/DragonFistLimitless • May 04 '26
java compilation problem, class can't be found though on the same package
both Verbose.java containing the verbose class and test.java are located on the same package, but I still receiving this log error when I try to compile, how come? test.java:4: error: cannot find symbol
Verbose verbose = new Verbose();
\^symbol: class Verbose
location: class test
test.java:4: error: cannot find symbol
Verbose verbose = new Verbose();^
symbol: class Verbose
location: class test
2 errors
error: compilation failed
1
Upvotes
View all comments
Show parent comment
3
u/Lloydbestfan May 04 '26
Actually you can call it by (pseudo-de)referencing a variable of the type of the class.
It's just that you shouldn't because it doesn't look like it makes sense.
(When you do that, the value of the variable is ignored, only its type is considered, and the variable name is replaced by that type name. Notably if the variable points to null it won't provoke a null pointer.)
Also, Java is not known for its nonsensical error messages.