我写了一个测试程序public class test
{
public static void main(String[] args)
{
byte[]t1=new byte[50];
byte[]t2=new byte[50]; t1[0]='a';//这两句赋值 要与不要 结果都一样的
t2[0]='a'; System.out.println(t1.equals(t2));
}
}输出结构是 false请教这是什么原因
用什么方法才能得出正确的结果?
{
public static void main(String[] args)
{
byte[]t1=new byte[50];
byte[]t2=new byte[50]; t1[0]='a';//这两句赋值 要与不要 结果都一样的
t2[0]='a'; System.out.println(t1.equals(t2));
}
}输出结构是 false请教这是什么原因
用什么方法才能得出正确的结果?
for (int i = 0; i < t1.length; ++i) {
if (t1[i] != t2[i]) {
System.out.println("不同");
return;
}
}
System.out.println("相同");
return;
}