Page 1 of 1

Why this code generate compile time error?

Posted: Sat Aug 04, 2007 6:38 am
by mjahan
why the following code generate compile time error?

import java.util.*;

public class hasmat
{
public static void main(String args[])
{
long a, b=9;

Scanner test = new Scanner(System.in);

while(test.hasNextLong())
{
a= test.nextLong();

if(test.hasNextLong())
b= test.nextLong();

if(a>b)
System.out.println(a-b);
else
System.out.println(b-a);
}

}
}

Posted: Sat Aug 04, 2007 4:04 pm
by chunyi81
I believe your code is written for Java JDK 1.5 (Java SDK 5.0)?

The Java compiler in the OJ is gcj, which supports a Java JDK 1.1 and a subset of Java JDK 1.2

Posted: Thu Dec 20, 2007 10:46 am
by pronebear
Your class name should be "Main".