if (check == false)
{
        i = 2;
        i = i + 2;
}
else
        i = i + 4;

-----Original Message-----
From: Miao, Franco CAWS:EX [mailto:[EMAIL PROTECTED]]
Sent: Monday, January 14, 2002 5:35 PM
To: [EMAIL PROTECTED]
Subject: A java question.


class test {
    static boolean check;
    public static void main(String args[]) {
        int i;
        if(check == true)
            i=1;
        else
            i=2;

        if (check == false)
            i=2; i=i+2;

        else
            i = i + 4;

        System.out.println(i);
     }
}


C:\>javac test.java
test.java:13: 'else' without 'if'
        else
        ^

I know this is cause by  i=2; i=i+2;
if just i=2, then everthing will be fine, how to make  i=2; i=i+2; as a
block, so compiler will not consider it should need another "if" ?

Franco

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://archives.java.sun.com/jsp-interest.html
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.jsp
 http://www.jguru.com/faq/index.jsp
 http://www.jspinsider.com

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://archives.java.sun.com/jsp-interest.html
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.jsp
 http://www.jguru.com/faq/index.jsp
 http://www.jspinsider.com

Reply via email to