Click here to Skip to main content
15,887,328 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
Method that flipping the tile to the opposite color.
Is this the correct way to set it up.
I get the correct out put when I print out the statement x[0] and x[1].
But when I try print out x[i], i get white over white, why is that

public class Tile
{
    protected String emptyTile;
    protected String black;
    protected  String  white;

    public String [] Flipping()
    {
        String temp;
        String[]x={"Black","White"};

        for(int i=0;i<x.length;i++)
        {
            temp=x[1];
            x[1]=x[0];
            x[0]=temp;
            System.out.println(x[0]+" ");
             System.out.println(x[1]+" ");
        }
        return x;
    }
}
Posted
Updated 3-Oct-13 8:45am
v4
Comments
Richard MacCutchan 4-Oct-13 4:29am    
I just tried this and it works fine; maybe you are not showing exactly where the error occurs.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900