请教大神们一个java基础问题
程序为publicclassWeiOne{publicstaticvoidmain(Stringargs[]){Stringbinary[]={"0000","0001"...
程序为
public class WeiOne{
public static void main(String args[]){
String binary[]={"0000","0001","0010","0011","0100","0101","0110","0111","1000","1001","1010","1011","1100","1101","1111"};
int a=3;
int b=6;
int c=a|b;
int d=a&b;
int e=a^b;
int f=((~a&b)|(~b&a));
int g=~a & 0x0f;
System.out.println(binary[a]);
System.out.println(binary[b]);
System.out.println(binary[c]);
System.out.println(binary[d]);
System.out.println(binary[e]);
System.out.println(binary[f]);
System.out.println(binary[g]);
}
javac编译时报错信息
javac WeiOne.java
WeiOne.java:62: 错误: 未结束的字符串文字
"}
^
WeiOne.java:62: 错误: 解析时已到达文件结尾
"}
请教下大神,这段程序到底是哪里出了问题 展开
public class WeiOne{
public static void main(String args[]){
String binary[]={"0000","0001","0010","0011","0100","0101","0110","0111","1000","1001","1010","1011","1100","1101","1111"};
int a=3;
int b=6;
int c=a|b;
int d=a&b;
int e=a^b;
int f=((~a&b)|(~b&a));
int g=~a & 0x0f;
System.out.println(binary[a]);
System.out.println(binary[b]);
System.out.println(binary[c]);
System.out.println(binary[d]);
System.out.println(binary[e]);
System.out.println(binary[f]);
System.out.println(binary[g]);
}
javac编译时报错信息
javac WeiOne.java
WeiOne.java:62: 错误: 未结束的字符串文字
"}
^
WeiOne.java:62: 错误: 解析时已到达文件结尾
"}
请教下大神,这段程序到底是哪里出了问题 展开
1个回答
2018-01-24 · 百度知道合伙人官方认证企业
尚学堂科技有限公司
北京尚学堂科技有限公司是一家从事JAVA、大数据、web前端、网络在线教育、互联网架构师、Android、ios技术开发、咨询为一体的软件公司。公司由海外留学人员和国内IT人士创建。
向TA提问
关注
展开全部
缺少一个“}”
public class WeiOne {
public static void main(String args[]) {
String binary[] = { "0000", "0001", "0010", "0011", "0100", "0101", "0110", "0111", "1000", "1001", "1010",
"1011", "1100", "1101", "1111" };
int a = 3;
int b = 6;
int c = a | b;
int d = a & b;
int e = a ^ b;
int f = ((~a & b) | (~b & a));
int g = ~a & 0x0f;
System.out.println(binary[a]);
System.out.println(binary[b]);
System.out.println(binary[c]);
System.out.println(binary[d]);
System.out.println(binary[e]);
System.out.println(binary[f]);
System.out.println(binary[g]);
}
} // 此处却少一个花括号
追问
..不好意思大神,最后一个括号是加上了的,因为在复制的时候}在最后一行没复制上
System.out.println(binary[g]);
}
}
追答
编码格式没统一,把编码换成utf-8试试。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询