substring 的菜鸟问题
String temp= "\tghi ";
String temp1=temp.substring(0,0);
String temp2=temp.substring(0,1); //watch是 "\t "
System.out.println(temp1.length());//输出是0
System.out.println(temp2.length());//输出1
if (temp1== " ")
{
System.out.println( "here ");
}
else
{
System.out.println( "there ");//执行这条语句
}
if (temp2== " ")
{
System.out.println( "Null ");
}
else
{
System.out.println( "NOt Null ");//执行这条语句
}
请问这是为什么啊?谢谢
------解决方案--------------------用equals,不要用==