Sunday, December 23, 2018

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( System.in ); 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 == %d\n", n1, n2 ); if ( n1 != n2 )
10System.out.printf( "%d != %d\n", n1, n2 ); if ( n1 < n2 )
11System.out.printf( "%d < %d\n", n1, n2 ); if ( n1 > n2 )
12System.out.printf( "%d > %d\n", n1, n2 ); if ( n1 <= n2 )
13System.out.printf( "%d <= %d\n", n1, n2 ); if ( n1 >= n2 )
14System.out.printf( "%d >= %d\n", n1, n2 );
15}
16}

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).



Reviewer: FajarYusuf.Com
ItemReviewed: Statement IF & Relationships JAVA Operator

Seseorang yang ingin membagi pengalaman dan ilmu yang berguna untuk para pembaca FajarYusuf.Com :)

TENTANG SITUS

SITUS INI ADALAH SITUS PEMBELAJARAN PEMROGRAMAN DAN JUGA PEMAHAMAN TERHADAP TEKNOLOGI KOMPUTER. KALIAN BISA MENGIKUTI PEMBELAJARAN PEMROGRAMAN DENGAN BERTAHAP PADA MATERI YANG SUDAH SAYA SEDIAKAN, JIKA ADA MATERI YANG MEMBINGUNGKAN SILAKAN LAKUKAN KOMENTAR PADA MATERI YANG ANDA TANYAKAN ATAU KALIAN BISA MENGHUBUNGI SAYA DIHALAMAN KONTAK.