Whenever you have to write a statement block within "if" or "else", use { and } to wrap the statement block. Ur way only works for a single statement. Try this code :
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); } } -----Original Message----- From: Miao, Franco CAWS:EX [mailto:[EMAIL PROTECTED]] Sent: Tuesday, January 15, 2002 4:05 AM 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 "THIS E-MAIL MESSAGE ALONG WITH ANY ATTACHMENTS IS INTENDED ONLY FOR THE ADDRESSEE and may contain confidential and privileged information. If the reader of this message is not the intended recipient, you are notified that any dissemination, distribution or copy of this communication is strictly Prohibited. If you have received this message by error, please notify us immediately, return the original mail to the sender and delete the message from your system." =========================================================================== 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