I have a java code ,cannot understand interface

Here is the code i have three interfaces

interface i1{ 
int x=1;
}
interface i2{ 
int x=2;
}
interface i3{ 
int x=3;
}
class A implements i1,i2,i3{
system.out.println(x); // It shows Field is ambgous
}

How to answer this or how to overcome this problem.

Jon Skeet
people
quotationmark

How to answer this or how to overcome this problem.

Don't use fields in interfaces, or if you must use them, and they must have the same names, just fully qualify them:

System.out.println(i3.x);

Note that with import static, the "brevity" reason for importing interfaces containing constants is removed - interfaces should really only be implemented for genuine behavioural reasons. See Effective Java 2nd edition for more advice on this front.

people

See more on this question at Stackoverflow