JavaRush /Java Blog /Random EN /Comments in the Java language
articles
Level 15

Comments in the Java language

Published in the Random EN group
Comments in Java, as in most other programming languages, are ignored when a program is executed. Thus, you can add as many comments to the program as you need without fear of increasing its size. Comments in Java - 1The Java language has three ways to highlight comments in text. The most common use is two slashes //, with the comment starting immediately after the characters //and continuing to the end of the line.
System.out.println("Hello, Java world!");
// наш комментарий
If you need longer comments, you can start each line with characters. While it's more convenient to delimit comment blocks with /*and */.
/*
 Пример простой программы на Java
*/

public class SampleProgram
{
 public static void main (String [] args)
 {
 System.out.println("Hello, Java world!");
 }
}
It should not be forgotten that comments separated by characters /*and */in the Java language cannot be nested. This means that a piece of code cannot be disabled by simply surrounding it with /*and */, because the code being disabled can itself contain the separators /*and */. Link to the original source: Comments in the Java language
Comments
TO VIEW ALL COMMENTS OR TO MAKE A COMMENT,
GO TO FULL VERSION