Counting sort using arrays
I'm sorry, but I think this is the time where it's easier to start from scratch then try to fix your code.
Let me comment on some of your styling choices:

Don't use words like smallest/anothersmallest/largest etc - use min/max.
Respect the CamelCase for long variable names.
Don't initialize your loop counter in the beginning where you initialize all other variables.
n is unnecessary and while you created it - you don't use it everywhere.

Logic
The first loop where you calculate min and max is fine.
The second loop inside the loop is not necessary. Instead you could just use something like (assuming you would use min for smallest value and counts for temp array):
for (int i=0; i&lt;a.length; i++) {
   counts[a[i]-min]++
}

The third loop where you populate result back on what you counted so far can be written like:
int j=0;
for (int i=0; i&lt;counts.length; i++) {
   while (counts[i] &gt; 0) {
      result[j] = i + min;
      counts[i]--;
      j++;
   }
}