public class Test080616{
public static void main(String[] args) {
if ( System.getProperty("user.language") == "en" ) {
System.out.println("english");
}
System.out.println(System.getProperty("user.language"));
System.out.println(System.getProperty("user.language").length());
}
}请看以上代码, 我打印出来System.getProperty("user.language")的值确实是en,但是我将用在if中,if语句中的代码始终都不会执行(开始我还以为里面有空格存在,结果我打印其长度,长度却是2.),想了很久都不知道为什么?请那位高手帮忙看以下! 非常感谢!
public static void main(String[] args) {
if ( System.getProperty("user.language") == "en" ) {
System.out.println("english");
}
System.out.println(System.getProperty("user.language"));
System.out.println(System.getProperty("user.language").length());
}
}请看以上代码, 我打印出来System.getProperty("user.language")的值确实是en,但是我将用在if中,if语句中的代码始终都不会执行(开始我还以为里面有空格存在,结果我打印其长度,长度却是2.),想了很久都不知道为什么?请那位高手帮忙看以下! 非常感谢!
System.out.println("english");
}
===> if ("en".equals( System.getProperty("user.language") )) {
System.out.println("english");
}
System.out.println("english");
}