如何打印存储在以Java存储在数组中的对象中的字符串

时间:2014-03-17 12:16:02

标签: java arrays

public static void main(String[] args)
    {
        Rubik[][][] pos = new CubePos[3][3][3];
        CubePos getter = new CubePos();

        //RED FACING FRONT, ORANGE ON BACK
        //BLUE ON TOP, GREEN ON BOTTOM
        //YELLOW TO THE RIGHT OF USER, WHITE TO THE LEFT OF USER
        pos[1][1][2] = new CubePos(new CubeOne("R", CubeColor.Color.Red), CubeColor.Color.Red);
        pos[2][1][1] = new CubePos(new CubeOne("Y", CubeColor.Color.Yellow), CubeColor.Color.Yellow);
        pos[1][1][0] = new CubePos(new CubeOne("O", CubeColor.Color.Orange), CubeColor.Color.Orange);
        pos[0][1][1] = new CubePos(new CubeOne("W", CubeColor.Color.White), CubeColor.Color.White);
        pos[1][2][1] = new CubePos(new CubeOne("B", CubeColor.Color.Blue), CubeColor.Color.Blue);
        pos[1][0][1] = new CubePos(new CubeOne("G", CubeColor.Color.Green), CubeColor.Color.Green);

如果存储在阵列中,如何打印“R”“Y”“O”等?

1 个答案:

答案 0 :(得分:1)

System.out.println(pos[1][1][2].getCubeOne().getCubeOneLetter());

用你的方法替换方法名称。