Why this code generate compile time error?

Write here if you have problems with your Java source code

Moderator: Board moderators

Post Reply
mjahan
New poster
Posts: 1
Joined: Sat Aug 04, 2007 6:24 am

Why this code generate compile time error?

Post 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);
}

}
}
chunyi81
A great helper
Posts: 293
Joined: Sat Jun 21, 2003 4:19 am
Location: Singapore

Post 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
pronebear
New poster
Posts: 1
Joined: Thu Dec 20, 2007 10:22 am

Post by pronebear »

Your class name should be "Main".
Post Reply

Return to “Java”