java - Error reached end of file while parsing -
this java class
import java.util.scanner; public class first { public static void main(string args[]); int right_number, user_input; right_number = 6; scanner in = new scanner(system.in); system.out.println("enter number between 1 , 10"); user_input = input.nextint(); if(user_input = right_number) { system.out.println("that right number!"); } else { system.out.println("aww, try again typing java first commad line."); } }
it keeps saying this:
error reached end of file while parsing.
can help?
this first problem:
public static void main(string args[]);
you're not declaring method body here. should be:
public static void main(string[] args) { // method body goes here }
you should use ;
@ end of method declaration abstract methods (including implicitly abstract in interface). if haven't got abstract methods yet, ignore moment - use braces provide method body.
(the string[] args
vs string args[]
isn't problem such, version preferred matter of style... naming class first
rather first
... there various other style issues here, i'll leave @ now.)
the fact class "tries" end directly after else
statement should warning bell - else
statement can appear in method or constructor, there has brace close method/constructor , brace close class declaration itself. likewise, indentation should warn of - assuming you're using ide perform indentation, time find writing method body statements 1 level of indentation further class declaration, suggests have problem somewhere - file see starts.
Comments
Post a Comment