-5

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).

enter image description here

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?

Kurt Peek
  • 52,165
  • 91
  • 301
  • 526

2 Answers2

1

Actually its

System.out.print(count(a))

and for parsing integer use

Integer.parseInt(args[0])

I would like to suggest to go through JAVA tutorial or any beginner level java blog

http://www.tutorialspoint.com/java/

Jekin Kalariya
  • 3,475
  • 2
  • 20
  • 32
0

To write on console command in java is :

System.out.println(count(a));
Abhijeet
  • 4,069
  • 1
  • 22
  • 38