Page 227 - IT-802_class_12
P. 227

For single-line comments, the former method is preferred, whereas for multiple-line comments, the latter is recommended.
            Comments are used to make code more readable, but the compiler ignores them while compiling a file.
            If we ignore the comments, the Helloworld. Java program is as below:

            public class HelloWorld

            {
              public static void main (String[] args)
              {

                 }
            }
            Curly braces surround the content of a class. A main method has been declared within the Helloworld class’s contents.
            A method is a set of statements written to accomplish a specific task. The method body is surrounded by curly braces
            and contains the statements that the method will execute. Main is a special method that every Java application must
            have. When you run a program, the statements in the main method are the first to be executed. The HelloWorld class’s
            main method contains only a single line of comment.
            // TODO code application logic here

            Write this code to make the file as main class
              public static void main(String[]args)

              {
              }
            At this point, you can either continue typing the word out or browse down the displayed list until you find the wordout,
            then double-click or press enter. Another list shows when you type the dot after the word out. Continue typing or
            select println from the list once again. After you finish the line, your code editor window should look like this.





















            Don’t forget to finish the statement with a semicolon. A semicolon must be used at the end of every Java statement.
            NetBeans will notify you with a glyph - an exclamation point in a red circle - in the left margin of the line if you make
            any errors when typing your code, such as forgetting a semicolon at the conclusion of a statement or misspelling a
            keyword. You’ll find helpful tips to rectify the issues if you move the cursor near the warning. You can use these tips to
            fix your mistakes.









                                                                               Fundamentals of Java Programming  225
   222   223   224   225   226   227   228   229   230   231   232