Statement IF & Relationships JAVA Operator

Statement IF & Relationships JAVA Operator

Decision (IF Statement) and Operator Relations

If statement in Java is used to compare an expression that returns true or false. Operators relationships that can be used are as follows:
operator relasi
Examples of program coding javanya if and relationships are as follows:
01import java.util.Scanner;
02public class IFdanRelasi{
03public static void main( String args[] ){
04Scanner input = new Scanner( ); int n1;
05int n2;
06System.out.print"Input first integer number: " ); n1 = input.nextInt();
07System.out.print"Input second integer number: " ); n2 = input.nextInt();
08if ( n1 == n2 )
09System.out.printf( "%d == %dn", n1, n2 ); if ( n1 != n2 )
10System.out.printf( "%d != %dn", n1, n2 ); if ( n1 < n2 )
11System.out.printf( "%d < %dn", n1, n2 ); if ( n1 > n2 )
12System.out.printf( "%d > %dn", n1, n2 ); if ( n1 <= n2 )
13System.out.printf( "%d <= %dn", n1, n2 ); if ( n1 >= n2 )
14System.out.printf( "%d >= %dn", n1, n2 );
if and relasi java
the results of coding, in the example I enter the first number 2 and the second number 3 to be compared with the relation, visible results of the relation with the condition if fulfilled will be executed and display,  2! = 3 (two does not equal three) 2 <= 3 (two less than and equal to 3), 2 <3 (two less than three).

Spread the love

Fajar (Ucup)

The owner and author of and also someone who likes to share interesting information with others.

Leave a Reply

Your email address will not be published. Required fields are marked *