java中为什么toString输出 数组类 的时候会出现乱码?
packagea;classaa{publicStringa;publicStringb;publicaa(Stringa,Stringb){this.a=a;this....
package a;
class aa
{
public String a;
public String b;
public aa(String a,String b){this.a=a;this.b=b;}
public String toString(){return a+" "+b;}
}
public class a
{
public static void main(String args[])
{
Object b[]=new aa[3];
b[0]=new aa("1","2");
b[1]=new aa("2","3");
b[2]=new aa("3","4");
for(int i=0;i<b.length;i++)
{
System.out.println(b.toString());
}
}
}
结果是:
[La.aa;@6996db8
[La.aa;@6996db8
[La.aa;@6996db8 展开
class aa
{
public String a;
public String b;
public aa(String a,String b){this.a=a;this.b=b;}
public String toString(){return a+" "+b;}
}
public class a
{
public static void main(String args[])
{
Object b[]=new aa[3];
b[0]=new aa("1","2");
b[1]=new aa("2","3");
b[2]=new aa("3","4");
for(int i=0;i<b.length;i++)
{
System.out.println(b.toString());
}
}
}
结果是:
[La.aa;@6996db8
[La.aa;@6996db8
[La.aa;@6996db8 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询