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

Comments in Java

Published in the Random EN group
Comments in Java, as in most other programming languages, are ignored during program execution. Thus, you can add as many comments to the program as needed without fear of increasing its size. Comments in Java - 1Java has three ways to highlight comments in text. The most common use is two forward 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 symbols. Although it is more convenient to limit comment blocks to delimiters /*and */.
/*
 Пример простой программы на Java
*/

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