vysh
04-24-2009, 04:19 PM
Hi all,
I have declared a method in an interface and implementing it in a class. I havent given any access modifier in the interface and also in the class in which i have implemented which means that it has package access. But I am getting access privilege error.
My code is as follows:
interface DeclareStuff
{
public static final int EASY = 3;
void doStuff(int t);
}
public class TestDeclare implements DeclareStuff
{
public static void main(String [] args)
{
int x = 5;
new TestDeclare().doStuff(++x);
}
void doStuff(int s)
{
s += EASY + ++s;
System.out.println("s " + s);
}
}
And the error which i am getting is:
doStuff(int) in TestDeclare cannot implement doStuff(int) in DeclareStuff; attempting to assign weaker access privileges; was public
I have declared a method in an interface and implementing it in a class. I havent given any access modifier in the interface and also in the class in which i have implemented which means that it has package access. But I am getting access privilege error.
My code is as follows:
interface DeclareStuff
{
public static final int EASY = 3;
void doStuff(int t);
}
public class TestDeclare implements DeclareStuff
{
public static void main(String [] args)
{
int x = 5;
new TestDeclare().doStuff(++x);
}
void doStuff(int s)
{
s += EASY + ++s;
System.out.println("s " + s);
}
}
And the error which i am getting is:
doStuff(int) in TestDeclare cannot implement doStuff(int) in DeclareStuff; attempting to assign weaker access privileges; was public