STUDENT! LOVE, CARE, and KEPO about TECHNOLOGY! WHAT ABOUT YOU?
RSS
content top

Basic Programming 4

Tuesday, August 28th. 23:29 (add the time, for more 'GREGET')

Holla hop everyone!!
Finally, touch down “Basic Programming 4”
I am going to continue our last topic. Do you remember??
Correct!! About the operator. I have told you about, arithmetic, increment and decrement operator. There are two operator left, Logic operator, and relations operator.
Relations operator is used to compare two values and to show the connection between them.
Relations operator consist of : >, >=, <, <=, ==(are equal), != (aren’t equal)
This is the example how to use this operator.
public class Relasi
{
public static void main (String [] args)
                {
                int a=10;
                int b=5;




                if (a>b)
                {System.out.print ("Ya, a>b");}
                else
                {System.out.print ("Tidak benar a>b");}
                }
}
 


That the simple explanation about relations operator.

How about this one?
This codes will show us the different between x++ and ++x (our last topic about Decrement and increment)

import java.util.Scanner;
public class Relasi1
{
public static void main (String [] args)
{
                int a;
                System.out.println("Masukkan bilangan 1: ");
                Scanner scan = new Scanner (System.in);
                a= scan.nextInt();
                //Lebih besar sama dengan
                if (a>=++a)
                {
                                System.out.print("True");
                }
                else
                {
                System.out.println("False");
                }
                if (a>=a++)
                {
                                System.out.println("True");
                }
                else
                {
                System.out.println("False");
                }
}

}

  • Digg
  • Del.icio.us
  • StumbleUpon
  • Reddit
  • RSS

1 komentar:

Unknown mengatakan...

visit my site too
ST3 Telkom
and follow my social media instagram please :
Jalin Atma

Posting Komentar