Any body can help me with this error I am getting this error:
C:\Documents and Settings\Fuad Damra\Desktop\TCPDayTimeServer.java:33: variable out might not have been initialized
out.println("Server Sent Average: "+Avg);
^
1 error
When I am trying to execute this program:
import java.io.*;
import java.net.*;
import java.util.Date;
public class TCPDayTimeServer
{
public static void main(String args[])
{
PrintWriter out;
BufferedReader in;
String nwkLine;
int Sum=0;
double Avg=0;
int i;
try
{
ServerSocket server = new ServerSocket(21);
while(true)
{
for(i=1;i<=20;i++)
{
Socket link = server.accept();
System.out.println("Connection Number "+i+"accepted");
in = new BufferedReader(new InputStreamReader(link.getInputStream()));
out = new PrintWriter(new OutputStreamWriter(link.getOutputStream()));
String intime=in.readLine();
int NTime = Integer.parseInt(intime);
Sum+=NTime;
}//for
Avg=Sum/i;
out.println("Server Sent Average: "+Avg);
out.flush();
out.close();
}//while
}
catch(IOException ioe)
{System.out.println("io error");}
}
}