Saturday, July 18, 2009

Now we start to go about if and switch, learn java in the previous program we at least understand a little about if and switch. Here, there is little understanding of if and switch, although not so much but it is important for you to try the program before java is, at least at a glance, read with understanding what you can and if that switch. Welcome to try in learnjavaprogram

IF -> structure which only execute the activities that result in a boolean value true
syntax
if(boolean_expr);
or
if(boolean_expr) statement;
example:
if(grade > 70)
System.out.println("Passed");

**if/else is statement executed if the value of boolean expression true value and execute the statement that when expresinya boolean value is false. But if using / false
syntax
if(boolean_expr)
statement 1;
else
statement 2;

example
if((b*b-4.a*c)>=0.)
(System.out.println(“there are real roots”);
else
System.out.println(“there are complex roots”);

**Usually in programming options can be found once the complex. so if the / else if it is found that complex if / else can be sintak with the following;
syntax







example

if ( (b*b – 4. *a*c) >= 0. )
System.out.println(“there are real roots”);
else if((b*b-4.*a*c)==0.)
System.out.println("there are two identical real roots");
else
System.out.println(“there are complex roots”);

**if stratified is if the selection could have if, instead of false can have the false
syntax












**structure condition is operator for the condition of the structure with the mark (?:) is an equality if / else
structure
example:
System.out.println(grade>70?"passed":"Failed")


SWITCH -> One of the selection of the structure, the program will read the blocks in accordance with the values listed in an expression.
syntax

















information SWITCH
case is a switch statement that can be used for the selection process with a single variable that are, the core of the switch case itself is the selection process but which are only one variable in the SWITCH keyword, and there are several options in the keyword CASE.

0 comments:

Post a Comment

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Macys Printable Coupons