Results 1 to 6 of 6
  1. #1
    eel
    eel is offline Member
    Join Date
    Sep 2010
    Posts
    36
    Rep Power
    0

    Exclamation Help with if else error

    I don't know why I got the else without if error from the command window. I thought it's always

    if{


    }

    else
    {



    }

    But I still got the error. Can anyone help me with this?

  2. #2
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    12,997
    Blog Entries
    7
    Rep Power
    19

    Default

    Quote Originally Posted by eel View Post
    I don't know why I got the else without if error from the command window. I thought it's always
    It is but you probably have a spurious semicolon somewhere; please always show us the actual code that's giving you problems; also put a [code] tag before the code and a [/code] tag after the code for reasons of readability; help us to help you.

    kind regards,

    Jos

  3. #3
    eel
    eel is offline Member
    Join Date
    Sep 2010
    Posts
    36
    Rep Power
    0

    Default

    Below is my code:
    public class POP {


    public static void main(String[] args) {
    file f = new file();
    printwriter p = new printwriter();
    {
    if (args.length == null)


    }
    else
    {


    }
    }
    }

  4. #4
    guilty is offline Member
    Join Date
    Sep 2010
    Posts
    6
    Rep Power
    0

    Default

    Try changing this:
    Java Code:
    printwriter p = new printwriter();
    {
    	if (args.length == null)
    }
    to this:

    Java Code:
    printwriter p = new printwriter();
    if (args.length == null)
    {
    }

  5. #5
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    12,997
    Blog Entries
    7
    Rep Power
    19

    Default

    Quote Originally Posted by eel View Post
    Below is my code:
    public class POP {


    public static void main(String[] args) {
    file f = new file();
    printwriter p = new printwriter();
    {
    if (args.length == null)


    }
    else
    {


    }
    }
    }
    Look at your code: in a block { ... } you have an if-condition without a statement and after the block has finished you have an orphan else keyword. That doesn't make sense; throw it away and start again.

    kind regards,


    Jos

  6. #6
    eel
    eel is offline Member
    Join Date
    Sep 2010
    Posts
    36
    Rep Power
    0

Similar Threads

  1. java out of memory error-heap space error
    By elsanthosh in forum NetBeans
    Replies: 4
    Last Post: 06-15-2010, 09:31 AM
  2. Replies: 1
    Last Post: 03-10-2010, 01:53 PM
  3. Replies: 1
    Last Post: 12-05-2009, 07:28 AM
  4. Replies: 1
    Last Post: 10-26-2009, 04:38 PM
  5. Replies: 3
    Last Post: 01-23-2009, 08:53 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
  •