the exit phrase
Author |
Message |
Chinmay
|
Posted: Mon Jan 07, 2008 6:37 pm Post subject: the exit phrase |
|
|
Ok I have a if block inside a try block as such:
code: |
try {
if ("Hey".equals("hey") {
System.out.print("The above two are equal, which they are not!");
} else {
exit;
}
}
|
why would this gimme an syntax error and not exit the if and after ending the try block? |
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
HeavenAgain

|
Posted: Mon Jan 07, 2008 6:45 pm Post subject: RE:the exit phrase |
|
|
simple, its because thats not how you use try. look at the exception tut for detail about try & catch.
int your case, you do not need try at all, so your code will simply be
code: | if ("Hey".equals("hey")
System.out.print("The above two are equal, which they are not!");
else
System.out.println("they are not equal, because i am right"); |
if you MUST use exit, the syntax is System.exit(int status), unless you import static System class, you cannot just say exit, and static import is only supported in java1.6 i believe  |
|
|
|
|
 |
|
|