【发布时间】:2024-01-03 22:05:01
【问题描述】:
感谢您抽出宝贵时间帮助我。
我对“非静态...”错误有疑问,我不知道为什么。这是代码
public class Klient {
public static String output = "test";
public static void main(String[] args) throws Exception {
Socket socket = new Socket("localhost", 9898);
PrintStream PS = new PrintStream(socket.getOutputStream());
InputStreamReader IR = new InputStreamReader(socket.getInputStream());
BufferedReader BR = new BufferedReader(IR);
int i;
for (i = 0; i < 3; i++) {
output = BR.readLine();
Server2.setTekst(output);
}
(这只是代码的一部分。我知道这是在解释时结束)
还有其他类:
public class Server2 extends JFrame implements Runnable {
konsol = new JTextPane();
konsol.setEditable(false);
public void setTekst(String tekst) {
konsol.setText(tekst);
}
public void run() {
instance = new Server2();
instance.setVisible(true);
}
}
同样,这也只是代码的一部分。非常感谢您的帮助:)
【问题讨论】:
标签: java compiler-errors non-static