+ 3
In java the interface should have same name as file name, at the same time my main class also should have same name as file name
Iam getting error, as "it's already defined". But I can't give different name also, what should I do, can anybody help.
7 Respuestas
+ 2
~ swim ~ thank you, I'll try
+ 1
What does it say that is already defined? A variable name? A class name?
0
public interface GenDemo{
void add() ;
}
class imp implements GenDemo{
public void add() {
System.out.println("addition of two numbers");
}
}
public class GenDemo {
public static void main(String args[]) {
imp a=new imp();
a.add();
}
}
0
Just above the main , it showing "the type GenDemo is already defined"
0
Sonic yaa at class name not in interface. If I give different name to interface it shows " interface should define in its own file"