你好,我是java世界的新手,我陷入了我的代码,这将是一个非常好的litle hel p
即时通讯在此代码中遇到问题/
public class Variables {
boolean bit;
String name;
public Variables(int b, String name){
this.name = name;
bit = test(b);
}
public boolean test(int b) {
System.out.println(b);
if(b==49) {
return true;
}
if(b==48) {
return false;
}
else {
return false;
}
}
}
Run Code Online (Sandbox Code Playgroud)
问题是无论b的数量是多少,它都会保持真实的实际上是我试图得到一个数字1或0的女巫在一个字符和变换中的布尔t/f
提前致谢
更多代码
public class truthtable2 {
public ArrayList <Variables[]>bits = new ArrayList<>();
public truthtable2 (ArrayList <String> inputs){
String [] inputsTab = inputs.toArray(new String[inputs.size()]);
Variables[] bittab = new Variables[inputsTab.length];
int total = (int) …Run Code Online (Sandbox Code Playgroud) 我正在尝试在 javafx 上做一个简单的聊天应用程序\n我的实际问题是将更新插入可观察列表并将其设置在列表视图中的线程
\n\n我使用的代码:
\n\n String message_re\xc3\xa7u;\n try {\n out = new PrintWriter(socket.getOutputStream());\n in = new BufferedReader(new InputStreamReader(socket.getInputStream()));\n while (true) {\n message_re\xc3\xa7u = in.readLine();\n if (message_re\xc3\xa7u != null) {\n messagesRe\xc3\xa7us.add(message_re\xc3\xa7u); \n }\n if (message_re\xc3\xa7u.equals("QUIT")) {\n break;\n }\n }\n\n in.close();\n out.close();\n socket.close();\nRun Code Online (Sandbox Code Playgroud)\n\n我在一个可运行的类中执行此操作,一旦服务器触发一条消息,线程就会将该消息插入列表中并显示在列表视图上,但线程会终止而不是继续工作
\n\n我对其进行了搜索,每个人都说要使用 runlater,但我\xe2\x80\x99m 完全迷失了,我确实声明了 runlater,但我\xe2\x80\x99m 不知道如何执行它,所以欢迎任何帮助
\n\n谢谢
\n我在这里遇到一个小问题可能是因为我无法弄清楚如何使用try和catch.
我的方法有点长,但问题很简单.我有输入1输入2和输入3的变量没有初始化的问题 - 我无法初始化它们,因为我需要程序返回错误,以防这个变量没有定义,我不能再把它放在null能够找到这个错误.
如何进行?
public void print() {
boolean input1;
boolean input2;
boolean input3;
String gate;
boolean calc;
for (String a : operations.keySet()) {
if (Gate2.contains(operations.get(a).Gate)) {
if (inputs.containsKey(operations.get(a).input1)) {
input1 = inputs.get(operations.get(a).input1);
}
if (inputs.containsKey(operations.get(a).input2)) {
input2 = inputs.get(operations.get(a).input2);
}
if (result.containsKey(operations.get(a).input1)) {
input1 = result.get(operations.get(a).input1);
}
if (result.containsKey(operations.get(a).input2)) {
input2 = result.get(operations.get(a).input2);
}
gate = operations.get(a).Gate;
calc = cc.calc(input1, input2, gate);
result.put(a, calc);
}else if (Gate3.contains(operations.get(a).Gate)) {
if (inputs.containsKey(operations.get(a).input1)) {
input1 = inputs.get(operations.get(a).input1);
}
if …Run Code Online (Sandbox Code Playgroud)