The below code gets compiled successfully, wherein inside some class, I have written two methods with same name & same type signature. Am using Eclipse Oxygen 4.7.0 and I can see error Duplicate method show(int,int)
shown in red. But when I compile the code, its getting compiled successfully with correct output. When I run the same code in command prompt using javac
its validly not getting compiled.
package oops2;
class A6
{
int i, j;
void show(int i, int j)
{
System.out.println(" i & j : " +i + " " +j);
}
void show(int k, int l)
{
System.out.println("override or not");
}
void show(String s)
{
System.out.println("Entered str is "+s);
}
}
public class OverrideNoInherit
{
public static void main(String[] args)
{
// TODO Auto-generated method stub
A6 a = new A6();
a.show(20, 30);
a.show("this is it");
}
}
Here, I want to mention that when I click on run
on Eclipse, I get a pop-up saying
Errors exist in this project, proceed with launch?
Now, didn't this error mean that there are other classes in same project which had errors & thus did not get compile. I don't think this meant that despite there being errors in code, the programs would get compiled. Then what would be difference between warnings & errors?