I'm trying to print out an int[] array for this assignment I'm working on. My code is as follows:
import VacuumCleanerEnvironment.Constants;
import java.util.*;
/**
 * Agent Class
 * Student's Assignment
 */
public class Agent {
    private String action = null;
    public Agent() {
    }
    private boolean wallCheck(Set walls, int row, int col, int i){
        int[] temp = {row, col};
        if(i == 1){ // up
            temp[0]--;
        }else if(i == 2){ //right
            temp[1]++;
        }else if(i == 3){ // down
            temp[0]++;
        }else{ // left
            temp[1]--;
        }
        return walls.contains(temp);
    }
    private void addWall(Set walls, int row, int col, String dir){
        int[] temp = {row,col};
        if(dir == "up"){
            temp[0]--;
        }else if(dir == "left"){
            temp[1]--;
        }else if(dir == "right"){
            temp[1]++;
        }else if(dir == "down"){
            temp[0]++;
        }
        walls.add(temp);
    }
    /**
     * can return:
     *      "up", "right", "down", "left", "suck dirt", "stay idle"
     * @return String
     */
    public String action(boolean dirty, boolean bump,int row, int col){
        //System.out.println(Constants.SIZE);
        //System.out.println(Constants.initialDirtProb);
        //System.out.println(Constants.dirtyProb);
        //System.out.println(Constants.dirtSensorFailProb);
        //System.out.println(Constants.bumpSensorFailProb);
//        System.out.println("\nbump:" + bump);
//        System.out.println("dirty:" + dirty);
//        System.out.println("row:" + row);
//        System.out.println("col:" + col); 
        //int r = Constants.randomGen.getInt(4);
        Set<int[]> walls = new HashSet<int[]>();
//        int[] wallRoom = new int[2];
        if (dirty)
        {
            action="suck dirt";
        }
        else
        {
            if(bump == true){
                this.addWall(walls, row, col, action);
                System.out.print("Walls:" + walls);
                Iterator value = walls.iterator();
                while(value.hasNext()){
                    System.out.print("," + (int[])value.next());
                }
                System.out.println();
            }
            Random r = new Random();
            int i = r.nextInt(4);
            while(this.wallCheck(walls, row, col, i)){
                System.out.println("wallcheck: " + this.wallCheck(walls, row, col, i));
                i = r.nextInt(4);
            }
            if(i == 1) {
                action = "up";
            }
            else if(i == 2) {
                action = "right";
            }
            else if(i == 3) {
                action = "down";
            }
            else {
                action = "left";
            }
        }
     return action;
    }
}
I am actually having 2 problems:1) The method wallCheck isn't running and I'm assuming it's because the int[] values are being saved as references and not values. How can I check if my HashSet contains a specific int[] value? (used to locate the walls on a map). 2) Why are my values being cut off when I print out my HashSet "walls". They are printing out like this:
Walls:[[I@1515e375],[I@1515e375
Walls:[[I@4abd1f59],[I@4abd1f59
Walls:[[I@e4612e6],[I@e4612e6
Walls:[[I@6936b791],[I@6936b791
Thanks in advance!
-------------------------------- EDIT -------------------------------
Ok guys I figured out what the problem was. Like Dave said it Java doesn't print out array's nicely, so I had to print it out myself. Also, I was declaring the HashSet INSIDE the action method, that's why only 1 value was being stored.
