abstract class

M

marcpirat

hi

in a abstract class, i created a object.... i ha problem to access
it...




code:


public class Passerelle{
static List lstIpServeur;
static List lstIpClient;
static List lstPort;
public static void main(String[] args) throws IOException {
ServeurPasserelle serveurpasserelle = new ServeurPasserelle();
serveurpasserelle.start();
}
}

another class

code:
abstract public class Protocol {
public Passerelle passerelle;

public Protocol(){
passerelle = new Passerelle();
}
abstract public String processInput(String theInput, Socket
socket);
}


in another class (ServeurPasserelleThread )i do

code:
ProtocolPasserelleServeur protocol = new ProtocolPasserelleServeur();
protocol.processInput("test");


and the last class

code:
public class ProtocolPasserelleServeur extends Protocol{
private final int WAITING = 0;
private final int SENT = 1;
private int state = WAITING;
public String processInput(String theInput, Socket socket) {
lstIpServeur.add(socket.getInetAddress());
}
return theOutput;
}
}

java don't seem to like that

i'm not able to have access to Passerelle list...

any idea
 
V

VisionSet

i'm not able to have access to Passerelle list...

I don't see any class extending Passerelle in order to gain access, since
the lst object I think you refer to is not qualified.

try Passerelle.lstXXX
 
V

Viator

Your lstIpServeur has a package access (by default java gives this
access to instance and class variables) so you can access this in other
classes provided that they are in the same package. However,
lstIpServeur must be qualified.

Amit :)
 
M

marcpirat

VisionSet a écrit :
I don't see any class extending Passerelle in order to gain access, since
the lst object I think you refer to is not qualified.

try Passerelle.lstXXX

in protocol class, i create a passerelle object
 
A

amitkch

A passerelle is a passerelle and a lstIpServeur is a lstIpServeur.
Creating Passerelle instance somwhere does not mean that you can access
its member without qualifiying.

Amit :)
 

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

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,074
Latest member
StanleyFra

Latest Threads

Top