You can use "{" and "}" to create blocks.
Really some of these java questions can be answered quicker if you get a reference manual (like the Java in a Nutshell book)
-----Original Message-----
From: Miao, Franco CAWS:EX [mailto:[EMAIL PROTECTED]]
Sent: Monday, January 14, 2002 2:35 PM
To: [EMAIL PROTECTED]
Subject: A java question.
Importance: Low
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
