public int mode()
	{
		HashMap<Integer, Integer> modes = new HashMap<Integer, Integer>();
		
		for(int i = 0; i < x; i++)
			for(int j = 0; j < y; j++)
			{
				int num = array[i][j];
				
				if(modes.containsKey(num)) modes.put(num, modes.get(num) + 1);
				else modes.put(num, 1);
			}
		
		int mode = array[0][0];

		for(Integer m : modes.keySet())
		{	
			int count = modes.get(m);
			int modeCount = modes.get(mode);
			
			if(count > modeCount || (modeCount == count && mode > m)) mode = m;
		}
		
		return mode;
	}