I'm new to Java and am trying to implement some example code from a book on algorithms:
public class ThreeSum {
public static int count(int[] a)
{
int N = a.length;
int cnt = 0;
for (int i = 0; i < N; i++)
for (int j = i+1; j < N; j++)
for (int k = j+1; k < N; k++)
if (a[i] + a[j] + a[k] == 0)
cnt++;
return cnt;
}
public static void main(String[] args)
{
int[] a = In.readInts(args[0]);
StdOut.println(count(a));
}
}
In Netbeans 7.2, I entered this code in a New File in a New Project. However, I notice that the lines in the client program with In
and StdOut
are underlined with red squiggly lines and have warnings leading to suggestions to create the class (see below).
How could I get rid of these warnings? Do I have to import any libraries? Also, how could I run the main program with some example input in the Netbeans environment?