Curly brackets franco.. but we're getting a bit off topic for a jsp list.

if (blah)
        //do stuff
else
        //do other stuff

this will work only if there is one and only one statement after the "if"
and the "else"
if there are to be more than one statement then the code must be placed in a
code block via the infamous curly brackets
eg
if(blah){
        //do stuff
        // do more stuff
}else{
        //do other stuff
        //do more other stuff
}

check out the sun java tutorial for control structures if this isn't clear


Tref Gare
Web Developer MCSD/SCJP
eCommerce Group
Phone:  (03) 9221 4106
Mobile: 0409 556 478
Fax:    (03) 9941 4295

> -----Original Message-----
> From: Miao, Franco CAWS:EX [SMTP:[EMAIL PROTECTED]]
> Sent: Tuesday,15 January 2002 9:35
> 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