-
Hey guys!!
I am Tamas from Hungary. I am beginner java developer and i have got a little problem with inheritance. My source code:
package oroklodes;
class MyClass {
private int anInt=4;
public String toString() {
return "Instance of myClass.anInt"+anInt;
}
public static void main(String[] args) {
MyClass act = new MyClass();
act.toString();
}
}
The program is not working because i get an error message!! The message is:
Error: Could not find or load main class oroklodes.MyClass
I would be happy if somebody knew the solution.
-
Re: Hey guys!!
-
Re: Hey guys!!
Thread moved from Members Introductions
-
Re: Hey guys!!
Hi,
Your source code is correct,but error is in package name....You remove the first line in your code "package oroklodes;".....
I check its Executed....
class MyClass {
private int anInt=4;
public String toString() {
System.out.println("2");
System.out.println(anInt);
return "Instance of myClass.anInt"+anInt;
}
public static void main(String[] args) {
MyClass act = new MyClass();
System.out.println("1");
act.toString();
}
}
-
Re: Hey guys!!
Could you post the contents of the terminal/console for when you tried to execute the program that shows what directory you are in, the commandline you entered and the error message.
To copy the contents of the command prompt window:
Click on Icon in upper left corner
Select Edit
Select 'Select All' - The selection will show
Click in upper left again
Select Edit and click 'Copy'
Paste here.