Page 62 - iprime_V2.2_class8
P. 62

For example,

                  public class comments{

                  public static void main(String[] args){
                      System.out.println("Comment Examples");

                      // This is a single line comment.

                      /* This is
                      multiline

                      comment*/
                      /** These types of comments are used when you want to add HTML code

                     into your Java program*/

                      }
                  }
                  When  you  run  the  preceding  code,  only the  message "Comment Examples" appears  on  the

                  terminal. All the other comments are ignored by the compiler.

                      OPERATORS

                  An operator is a symbol that tells the compiler to perform specific mathematical or logical
                  calculations. It requires operands or values to perform calculations and return the desired
                  result.
                  For example:

                         int x = y + z;
                         or

                         int x = 10 + 20;

                  In the above example, the plus (+) operator is used to calculate the sum of the two variables (y and z)
                  or values (10 and 20). It calculates the sum and assigns the result to variable x.
                  There are various types of operators in Java, which are as follows:
                      Arithmetic operators
                      Relational operators

                      Logical operators
                      Unary operators
                      Assignment operators

                  Let's discuss these in detail.
                  Arithmetic Operators

                  Arithmetic operators are used to do basic mathematical calculations. They consist of both
                  unary operators, which operate on a single operand, and binary operators, which require two
                  operands.


                  60     iPRIME (Ver. 2.2)–VIII
   57   58   59   60   61   62   63   64   65   66   67