public class Myname {
public static void main(String args[]){
Letter s = new Letter(); s.setCaracter("s");
Letter e = new Letter(); e.setCaracter("e");
Letter a = new Letter(); a.setCaracter("a");
Letter r = new Letter(); r.setCaracter("r");
Letter y = new Letter(); y.setCaracter("y");
Letter o = new Letter(); o.setCaracter("o");
Letter u = new Letter(); u.setCaracter("u");
Letter n = new Letter(); n.setCaracter("n");
Letter g = new Letter(); g.setCaracter("g");
Letter name[] = new Letter[10];
name[0] = s;
name[1] = e;
name[2] = a;
name[3] = r;
name[4] = s;
name[5] = y;
name[6] = o;
name[7] = u;
name[8] = n;
name[9] = g;
System.out.println(nombre[0].);//HERE!
}
}
我想知道一种在控制台中打印所有数组名称 [] 及其所有内容的方法。看到这样的东西:searsyoung
我尝试过:
System.out.println(Arrays.toString(theArray));
它打印出奇怪的东西---->[Letter_Myname.Letter@1d5550d,...