Results 1 to 3 of 3
  1. #1
    saif is offline Member
    Join Date
    Jul 2012
    Posts
    17
    Rep Power
    0

    Default Help with if else project

    hello
    i am compiling my first if else but i got this error

    Java Code:
    D:\saif>javac MyIf.java
    MyIf.java:20: error: reached end of file while parsing
    }
     ^
    1 error
    here is my java codes

    Java Code:
    public class MyIf {
    
    public static void maain (String [] args) {
    
    int a1 = 5;
    int a2 = 2;
    
    int res; 
    
    if (a2 != 0 ) {
    
       res = a1 / a2;
       System.out.println ("Result is " + res);
    }
    
    else {
            System.out.println ("Error, a2 = 0");
    }
    
    }

  2. #2
    java.java is offline Member
    Join Date
    Jul 2012
    Posts
    9
    Rep Power
    0

    Default Re: Help with if else project

    You have missed to close one of the curly braces , put another brace at the end and it should work.. And also the main method is mispelt , correct the spelling...
    Last edited by java.java; 07-24-2012 at 10:42 AM.

  3. #3
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,178
    Rep Power
    20

    Default Re: Help with if else project

    This is why indenting your code properly is important.
    Count your brackets...
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. Replies: 1
    Last Post: 05-17-2012, 10:43 PM
  2. Creating a project in eclipse from existing project
    By Suraiya in forum New To Java
    Replies: 1
    Last Post: 10-08-2011, 10:14 AM
  3. How to convert from Ant project to maven project?
    By jiapei100 in forum New To Java
    Replies: 0
    Last Post: 06-08-2011, 11:01 AM
  4. Adding a project to an existing project
    By Seijuro in forum NetBeans
    Replies: 4
    Last Post: 08-08-2010, 11:15 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •