I use Netbeans IDE. Below is a line of code i was practicing with and whenever i applied the else statement it was always missing something. For an if statement the else part of the if statement will be executed if the expression is evaluated to a false,right? please check the code below and tell me what to do for an else part to work and give me samples too.I had to replace the else in the code section with if (fishermen <=2); cos it just keeps highlighting red syntax error.thanks.I need your help cos it's good to practice and practice and seek help for better understanding.
Well there's your first mistake, in my view. At this stage, I'd strongly advise you to use a decent text editor - Notepad+ works for me - and learn to compile and jar from the command line. However, that's by-the-by.
For an if statement the else part of the if statement will be executed if the expression is evaluated to a false,right?
please check the code below and tell me what to do for an else part to work...
Well, the main problem is your basic if statement:
if(fishermen <=2); does absolutely nothing.
And the reason is that terminating ";", which is a null statement.
The format for an if statement is:where "execution_block" =
The braces are only required if you have multiple statements in the block, but I'd advise you to ALWAYS put them in.
and give me samples too.
Erm, actually, why don't you read the tutorials? There are plenty in there, and it'll save my CTS.
Isn't it funny how there's always time and money enough to do it WRONG?
Articles by Winston can be found here