QUOTE(kru @ 7 Sep, 2008 - 11:11 AM)

Ok, thanks. It works now. Also with strings, you can't use "==" to compare objects. You have to use the .equals function.
Just one other thing, i would move away from the static stuff, heres how i would do the program
CODE
public class Counting
{
private String array[] = {"three", "three", "two"};
void run()
{
//Declar array
//String array[] = {"three", "three", "two"};
//print array
for (int i = 0; i < array.length; i++)
{
System.out.println(array[i] + ", ");
}
//compute and print the count number
int trackCount = count("three");
System.out.println("The word \"three\" appears " + trackCount + " times.");
}
public int count (String target)
{
int counter=0;
for(int i = 0; i < array.length; i++)
{
if (array[i].equals(target))
counter++;
}
return counter;
}
public static void main (String[] args)
{
Counting myProgram = new Counting();
myProgram.run();
}
}
Hope it helps a bit more
This post has been edited by bbq: 9 Sep, 2008 - 12:38 AM