static and non static

N

niraliu

i am trying to implement interface, and static method cannot be called
in non static method. So my one class is public static void main and
other is non-static.

Test file -----------------
public class Test {


public static void main(String args[]) {

byte [] encoded =Round.doOneRound(data,key);
}


Round -----------

public interface Round {

public byte[/*8*/] doOneRound( byte[/*8*/] data, byte[/*6*/] key );
/*public byte[/*8*/] doOneRound( byte[/*8*/] data, byte[/*6*/] key )


So the error i m getting is non static method doOneRound cannot be
referrenced from a static cor

please help me debug..
 
O

Oliver Wong

i am trying to implement interface, and static method cannot be called
in non static method. So my one class is public static void main and
other is non-static.

Test file -----------------
public class Test {


public static void main(String args[]) {

byte [] encoded =Round.doOneRound(data,key);
}


Round -----------

public interface Round {

public byte[/*8*/] doOneRound( byte[/*8*/] data, byte[/*6*/] key );
/*public byte[/*8*/] doOneRound( byte[/*8*/] data, byte[/*6*/] key )


So the error i m getting is non static method doOneRound cannot be
referrenced from a static cor

please help me debug..

You need to take a step back and go back to the basics. Your terminology
is all wrong (e.g. "my one class is public static void main"), and you seem
to have misunderstood the conceptual purpose of interfaces. If you have a
textbook, I suggest you slow down and go back to the last exercise that you
managed to solve and start from there. If you don't have a textbook, maybe
you should work through http://java.sun.com/docs/books/tutorial/

- Oliver
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,979
Messages
2,570,184
Members
46,722
Latest member
NelsonHeil

Latest Threads

Top