+ 2
Why the program is showing errors
interface MyInterfaceA { void display(); interface MyInterfaceB { void myMethod(); } } class NestedInterfaceDemo1 implements MyInterfaceA.MyInterfaceB { public void myMethod(){ System.out.println("Nested interface method"); } public static void main(String args[]){ MyInterfaceA.MyInterfaceB obj= new NestedInterfaceDemo1(); obj.myMethod(); } }
5 ответов
+ 5
Can you write this program in Sololearn Playground and share here?
+ 4
Kontham Shravani interface declaration is wrong. You have to implement multiple interface with comma not with dot.
No need to create object of interface.
+ 2
Kontham Shravani When I copied your code in Play Ground and run that then I got error of white space character.
Compare your code with this and see what you did mistake.
----------------
interface MyInterfaceA {
void display();
}
interface MyInterfaceB {
void show();
}
class Demo implements MyInterfaceA, MyInterfaceB {
public void display () {
System.out.println("My interface A");
}
public void show() {
System.out.println("My interface B");
}
public static void main(String[] args) {
Demo d = new Demo();
d.display();
d.show();
}
}
+ 1
Give me the proper answer in which line I have to remove white space .I can't understand what did you say
0
Run the program, you can understand that your program has some extra white-space characters. Remove those, then it works.
Edit:
Kontham Shravani
Sry for late response.. Is it resolved?
Nested interface?
There Whice space means :
Complier shows you error at line number: illegal charecter like \u00a0. Go to that line number and remove extra spaces which are there....