我一直在努力解决以下4个错误。
这是一个简短的可重复的例子:
import java.util.logging.Level1;
import java.io.OutputStream;
import java.io.InputStream;
import java.io.IOException;
import java.net.Socket;
import java.net.SocketAddress;
import java.util.logging.Logger;
public class RcvThread2 implements Runnable{
private static final int sizeBuf = 50;
private Socket clientSock;
private Logger logger;
private socketAddress clientAddress;
public RcvThread2(Socket clntSock, socketAddress clientAddress, Logger logger) {
this.clientSock = clntSock;
this.logger = logger;
this.clientAddress = clientAddress;
}
public void run(
try {
InputStream ins = clientSocket.getInputStream();
OutputStream outs = clientSocket.getOutputStream();
// ...
为什么我会收到这四个编译错误?我该如何修理它们?
error : cannot find symbol
import java.util.logging.Level1;
symbol: class Level1
location: package java.util.logging
error : cannot find symbol
InputStream ins = clientSocket.getInputStream();
symbol: variable clientSocket
location: class RcvThread2
error: cannot find symbol
OutputStream outs = clientSocket.getOutputStream();
symbol : variable clientSocket
location: class RcvThread2
答案 0 :(得分:3)
删除行import java.util.logging.Level1;
(不存在,我认为您需要import java.util.logging.Level
)。并且socketAddress clientAddress
应为SocketAddress clientAddress
(这就是您使用clientAddress
获取有关未定义方法的消息的原因。)