Slide 1
Slide 2
Slide 3

comments in java programming (V4)

No Comments

 

        Comments in Java are lines that cannot be executed in the program code. They are ignored by the Java compiler, and comments serve as notes or explanations for programmers to understand the purpose or logic of the code.
        There are two types of comments in Java:
  • Single-line Comments – start with //.
  • Multi-line Comments – enclosed between /* and */.

Source Code:

Copied!
public class comments {
	
	/**
	 * Method main
	 *
	 *
	 * @param args
	 *
	 */
	public static void main(String[] args) {
		// TODO: Add your code here
		int x = 10;
        int y = 20;
        System.out.println("x + y = "+(x + y)); // Output: 30
	}	
}

Result:


Watch the video:




back to top