Java Tutorial/Language/Comments

Материал из Java эксперт
Версия от 05:06, 1 июня 2010; Admin (обсуждение | вклад) (1 версия)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

Comments in general

It is good practice to write comments explaining your code.

There are two types of comments in Java, both with syntax similar to comments in C and C++.

  1. Traditional comments: Enclose a traditional comment in /* and */.
  2. End-of-line comments: Use double slashes (//) which causes the rest of the line ignored by the compiler.

Traditional comments do not nest, which means



/*
  /* comment 1 */
  comment 2 */





Multiple lines of comment

/*   multiple lines of comment
another line
 */ 
public class MainClass{
  public static void main(String[] arg){
     
  }
}





Program Comments: Single line of comment

//   Single line of comment
public class MainClass{
  public static void main(String[] arg){
     
  }
}