a Dreamer

dreams out loud

Java Programming : Operator "?"

       We've known in every programming language what we called Operator. Operator is such methode to modify our variables in the programm, such as Arithmatics Operator, or Logic Operator.

      Aritmatic Operator : +, -, *, /, ++, --

      Logic Operators : >, <, <=, >= , ==, !=

      In java programming language we know an additonal Operator, "?". this operator use to replace if-else  to modify some variable for some condition. thats how we use "?" Operator in code :

     varX  = condition ? value(if  true) : value (if false);
      This is the sampel :
      From the code abpve we knew that harike is a variable that the value is a random value from 0 to seven. and value of ket variable depend on the value of harike, if harike == 0, the value of ket will be "hari libur" else  the  value of ket will be "hari kerja".

     This is the result :

0 argumen:

    Follower