Page 60 - iPlus_Ver_2.0_class_8
P. 60

Quick Byte

                      We can also assign values to variables after declaration in the following way:

                             age = 30;
                             name = "Nisha";

                             temp = 35.7f;
                             price = 625.50;

                  Comments

                  A comment is a statement in a Java program that is not executed by the Java compiler. Generally,
                  comments are used to give additional information about the code for understanding the code
                  better.

                  There are three techniques for adding comments to your Java programs, each of which has its
                  own particular usage. These techniques are as follows:
                  •   Using //: Use the two forward slashes to comment out text that appears after the forward
                     slashes but on the same line.

                  •   Using /* and */: Use the /* to turn on comments, and all text will be commented until a */ is
                     reached. This is useful for commenting out multiple lines of code.
                  •   Using /** and */:  A  special  type  of  comment  used  specifically  with  the  javadoc  tool  for
                     generating HTML files that contain your comments. This feature of Java is widely used, and it is
                     expected that the HTML pages accompany any Java code that is distributed among developers.

                  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" will appear on the
                  terminal. All the comments are ignored by the compiler.


                   i +  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 returns the desired
                  result.


                    58
                         iPlus (Ver. 2.0)-VIII
   55   56   57   58   59   60   61   62   63   64   65