0

Hi,
I created a class named Test.java

public class Test {
	public Test() {
		System.out.println("Testing......");
	}
}

It sucessfully compiles.
Then i create another java class Menu.java and here i trying to create an object of the Test class.

class Menu {
	
	public static void main(String[] args) {
	
		Test arrList = new Test();
		
	}
}

I got an error "Test cannot resolved to a type error " while i compile the Menu.java
I am new to java
Anyone can help ?
Thanks in advance.

Edited by pssubash: code

3
Contributors
6
Replies
8
Views
6 Years
Discussion Span
Last Post by javaAddict
0

You need to have both the class files in a same folder. The error means I couldn't resolve(find) the Type Test Class.

0

Yes,it aleady resides the same folder.but the iuuse will come.
Please find the attached files

Edited by pssubash: n/a

Attachments
import java.util.ArrayList;
class Menu {
	
	public static void main(String[] args) {
	
		Test arrList = new Test();
		
	}
}
public class Test {
	public Test() {
		System.out.println("Testing......");
	}
}
0

Do you have both the .class files and the java files in the same folder?
Test.java, Test.class, Menu.java, Menu.class ? I checked the code and it is correct.

The difference is that I have declared a package. The code should work without one. But is is better to use one. The right way would be to declare a package and set to the classpath the location of that package.

Can you verify at least that all of the above files mentioned are in the same folder?

0

Menu.class is not there,rest is there.
I got the above specified error while i am trying to compile Menu.java.
OS using : Linux

0

No one have any idea about it ?
Hope this is a small error ?
Can any one help me ?

0

Have you tried to declare a package at those classes?
Don't forget to set the classpath as well. There are instructions you can follow. Look at the tutorials at the top of the java forum

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.