Thursday, March 17, 2022

Comments in Java

 

java comments-

  • comments illustrate  java code and it makes the code more smooth and lucid
  • lines of code inside the comments are isolated by  the compiler in time of the compiling process......
  • Single-line Comments
  • Single-line comments start with two forward slashes (//).

Anything between // and the end of the line is ignored by Java compiler (will not be executed).

This example uses a single-line comment before a line of code:


Example

  1.public class Best{

  public static void main(String[] args) {

   // This is a comment

      System.out.println("Welcome to techy sowmii");

     }

     }

output: Welcome to techy sowmii

comments are not executed by compiler

 2.public class Best{

  public static void main(String[] args) {

   // This is a comment

      System.out.println("Welcome to techy sowmii");   // This is a comment

     }

     }

output: Welcome to techy sowmii

you can use java comments all over between the lines of code

Java Multi-line Comments

  • Multi-line comments start with /* and ends with */.
  • Anything between /* and */ will be ignored by Java compiler in time of compiling and execution process
  • Example

public class Best{

/* The code below will print the words Hello World

to the screen, and it is incredible*/

  public static void main(String[] args) {

      System.out.println("Welcome to techy sowmii");  

     }

     }

Normally, we use // for short comments

 /* */ for longer comments.

Related articles

JAVA VARIABLES

Beginner guide for java -1

why java

Explore JDK,JVM,JRE versions

A simple pillow talk between java and java user!!!!!!!!........

write java code in a simple text editor

java setup path for windows

java syntax-1

Java Syntax Explanation

Java Declare Multiple Variables

Java Print Variables

Comments in Java

No comments:

Post a Comment

Did you find this article helpful?
😁 😀

Java identifers

  Identifiers All Java variables must be identified with unique names . For example -different people have different names These unique ...