Basically I’m rather new to Java and I have a problem with understanding a line and getting it to work.
Heres the line of code:
LinkedList<ClientWorkers> clients = SingletonClients.getClients();
Heres the procedure its in:
ClientWorker(Socket client, JTextArea textArea) {
this.client = client;
this.textArea = textArea;
String line = in.readLine();
LinkedList<ClientWorkers> clients = SingletonClients.getClients();
for(int i = 0; i < clients.size(); i++) {
ClientWorker c = clients.get(i);
//The client doesn't need to get it's own data back.
if(c == this){
continue;
}
c.writeString(line);
}
}
The errors it’s throwing are:
SocketThrdServer.java:20: cannot find symbol
symbol : class LinkedList
location: class ClientWorker
LinkedList<ClientWorker> clients = SingletonClients.getClients();
^
SocketThrdServer.java:20: cannot find symbol
symbol : variable
SingletonClients location: class ClientWorker
LinkedList<ClientWorker> clients = SingletonClients.getClients();
Does anyone have any idea how I can get it sorted? I’m assuming the LinkedList is being defined wrong and SingletonClients isn’t being defined at all but I’m not sure what to define them as in this context?
Thanks in advance!
You need to
import java.util.LinkedList;at the beginning of the java file if you want to use LinkedList without its fully qualified name (i.e. if you want to be able to say “LinkedList” instead of “java.util.LinkedList”).