Java – Basics and Comments


Let’s start with simple Hello Poftut application. In application development comments are important because it provides clues about code. Comments are not included in code whiles compiling, interpreting or executing. They are just text can be read in code to give some hints. In java to mark comments // and /* */ are used .For example in the following code italic part is just comment and not compiled with the application.

public class HelloPoftut {
 public static void main(String[] args) {
 /*
 Start of the app
 */
 System.out.print("Hello Poftut");
 //Prints Hello Poftut
 }
 }


 public class HelloPoftut {
 public static void main(String[] args) {
 /*
 Start of the app
 */
 System.out.print("Hello Poftut");
 //Prints Hello Poftut
 }
 }

Comments are important before beginning because we will use comments to explain code, take notes and similar things. Now actually above code is runnable simple java application. To execute is first we should compile the code. Here we can compile it with cli tool javac or use IDE to make all things. We use eclipse and compile it.

Case Sensitivity

Java is case sensitive language which means using age with AGE is not the same even Age. Always be aware of that because it will give compilation errors.

Age != age != AGE

In this application we focus on public static void main … line and below we will touch other parts later. When an application starts it will look for main method. Program execution instructions runs from top to down.

Comments

Here

 /* Start of the app */ 1 2 3  /* Start of the app */

part is comment as stated before and compile operation removes them from executable file.

System.out.print("Hello Poftut");
 1
 System.out.print("Hello Poftut");

is real code runs when application starts. It simply prints “Hello Poftut”.

Next line is comment to and we added it to explain previous line by simply saying “prints Hello Poftut”. Think it a message to other people that reads this code.

LEARN MORE  C Syntax and Basics

Java expressions end with ; . As you see in example generally all expression lines have ; . Expression is atomic struct to express something like data, operation etc.

1 thought on “Java – Basics and Comments”

Leave a Comment