Tidy up number counting code
There is much to say about this piece of code. I'll just focus on some parts of it.

One long method

There is one long main method. It makes it hard to get an overview of what is happening. Consider breaking the main method into several methods that each does its piece. Something like.

public static void main(String...args){
    int[] randomNumbers = generateNumbers();
    String result = format(randomNumbers);
    result += formatNumberOfOccurences(randomNumbers);
    result += formatGraph(randomNumber);
    System.out.println(result);
}

// 4 methods omitted....


In this way you will get smaller chunks that is easier to understand. Each of these methods except the number generator is also easy to unit test since the outcome is the same for each argument. The code you have now is hard to unit test.

Printing with System.out

This is handy in many ways. But this is the main reason you need two loops for the code you have highlighted. Since you want to print the occurrence count first and then the graph you ned to do it in separate loops. If you instead store the intermediate result in a local variable then you can do it in one loop. Something like:

String occurrencesReport = "";
String graph = "";

for (int countOfNumbers = 0; countOfNumbers &lt; countOfArray.length; countOfNumbers++)
{
    occurrencesReport += "The number " + (countOfNumbers + 1) + 
        " occurs " + countOfArray[countOfNumbers] + " times.";

    if (countOfNumbers != 9)
        graph += (countOfNumbers + 1) + "   ";
    else
        graph += (countOfNumbers + 1) + "  ";

    for (int a = 0; a &lt; countOfArray[countOfNumbers]; a++)
    {
        graph += "*";
    }
    graph += "\n";
}

System.out.println(occurrencesReport);
System.out.println(graph);


Readability example

This little piece:

if (countOfNumbers != 9)
    graph += (countOfNumbers + 1) + "   ";
else
    graph += (countOfNumbers + 1) + "  ";


can be simplified like so:

graph += (countOfNumbers + 1) + "  ";
if (countOfNumbers != 9) graph += " ";


this makes it easier to understand what is going on. (On a side note - most people dislike the absence of curly braces in this code snippet. If you add a statement yo your if-block it will actually be outside if curly braces are omitted. I tend to do ifs on one line when they are short. But people don't like that either....) This example can be applied to at least one more piece of the code where there is unnecessary repetition.

Better stop now - just some bits and pieces I hope you can use to improve!