3105 (array histogram special case max 3)

public class hist
{
    
    public static int[] histogram (int [][] arrayA)
    {  // nested for loop to go through the array.
        int max = 0;
       for ( int row = 0; row<arrayA.length; row++)
		{
           for ( int col=0; col < arrayA[row].length; col++)
			{

               if ( arrayA[row][col]> max )
				{
                   max = arrayA[row][col];
            	}
        	}
    	}
	System.out.println("max:"+max);
    int histA[] = new int [max+1];
	int lauf = 0;
	for (lauf=0;lauf<max+1;lauf++)
	{
    for ( int row = 0; row<arrayA.length; row++)
		{
           for ( int col=0; col < arrayA[row].length; col++)
			{
				if (arrayA[row][col] == lauf)
				{
					histA[lauf]++;
				}
               //histA[arrayA[row][col]]++;
            }
        }
	}
        //System.out.println(histA);
        return histA;
    }
	public static void main (String[]args)
    {
        // declearing and initializing a 2D array.
        int [][] arrayA = {{0,1,2},{3,0,2},{3,3,0}};
		int erg[]={};
        erg = histogram(arrayA);
		for (int i = 0; i<=3; i++)
		{
			System.out.println(i+":"+erg[i]);
		}

    }
}