Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Help with this "ready-bake code", implementing Runnable

 
Tarek Khojah
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


The "ClientHandler" class implements Runnable, but when I create the thread (Thread t = new Thread(new ClientHandler(clientSocket)) I get an error saying there is no such constructor for ClientHandler, I looked into the API and it had nothing on Runnable's constructor(s).

Help please.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
public class ClientHandler

public void clientHandler (Socket clientSocket)

Capitalization matters in Java. The second line of code is currently not a constructor for the class.
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And if you do want it to be a constructor, you will need to get rid of the 'void', otherwise it will just be a method with the same name as the class.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic