views:

138

answers:

3

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!

+1  A: 

In the line

LinkedList<ClientWorkers> clients = SingletonClients.getClients();

you've written ClientWorkers instead of ClientWorker. This is an error. It should be:

LinkedList<ClientWorker> clients = SingletonClients.getClients();
Javi
Thanks so much! Never noticed that!Do you have any idea how to define SingletonClients?
It should be just a class called SingletonClients with a static method inside called getClients() which returns a LinkedList<ClientWorkers>.Something like: public class SingletonClients { public static LinkedList<ClientWorkers> getClients(){ //your code } }
Javi
+2  A: 

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").

sepp2k
Perfect! Thanks!Do you have any idea how to define SingletonClients?
+1  A: 

sounds like a classpath problem, although LinkdList belongs to the java.util package so it is always available. I suggest that you check the import statements at the top of your class file to see if you are using the correct LinkedList class

Yoni
Yeh it was exactly that! Thank you :D