Hi,
I'm doing a project for uni and not sure why this won't work. Still new to java so anything that's really out of whack let me know
Cheers in advance
public class Main { static public void main(String[] argv) { String read; Scanner in = new Scanner(System.in); Thread t1; System.out.print("Would you like to connect to the cinema? Y/N"); read = in.nextLine(); InetAddress adtep; adtep = new InetAddress(InetAddress.getByName(argv[0])); t1 = new Thread ( new readFromServer (adtep,5000)); if(read == "Y") { System.out.print("Connecting to server"); t1.start(); } if(read == "N"){System.out.print("exiting ");} else{System.out.print("Fail");} } class readFromServer implements Runnable { InetAddress addy; int port; DatagramSocket reSocket; DatagramPacket rePacket; byte[] buffer = new byte[1024]; public readFromServer (InetAddress addy, int port) { this.addy = addy; //initialize addy this.port = port; //initialize port try //Try has to be used to initialize these variables { this.reSocket.setSoTimeout(0); this.reSocket = new DatagramSocket(this.port); this.rePacket = new DatagramPacket(this.buffer,this.buffer.length); } catch(IOException ie) { System.out.print("Error: readFromServer.initializingVariables.001"+ " Please contact for this error"); try {Thread.sleep(1000); System.exit(1);} catch(InterruptedException iea){} } } readFromServer(String string, String string0) { throw new UnsupportedOperationException("Not yet implemented"); } public void run() { while(true) //The thread will continuously run to pick up data { //The following statement will wait untill data is recieved try{reSocket.receive(rePacket);} catch(IOException ie){} } } }