Decode Ways


  • 0
    V

    public String toString()// method that returns a string of the elements in the array
    {
    String array = "";

    	for(int i = 0; i < intArray.length; i++)//for each index of the array, it will check if there is an element (not empty) and concatenates the integer to the string
    	{
    		if(intArray[i] > 0) 
    		{
    			if((i % 10) == 0 && i != 0)//if i is divisible by 10 and is not 0, the string will add a new line character to print the next 10 elements
    			{
    				array += "\n"; 
    			}
    
    			array += intArray[i] + "\t"; 
    		}
    	}
    	return array; //returns the string of elements, separated by a tab with 10 integers per line
    }
    

    }


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.