import java.io.*; /** * 这个类演示了文档注释 * @author Ayan Amhed * @version 1.2 */ publicclassSquareNum{ /** * This method returns the square of num. * This is a multiline description. You can use * as many lines as you like. * @param num The value to be squared. * @return num squared. */ publicdoublesquare(double num){ return num * num; } /** * This method inputs a number from the user. * @return The value input as a double. * @exception IOException On input error. * @see IOException */ publicdoublegetNumber()throws IOException { InputStreamReader isr = new InputStreamReader(System.in); BufferedReader inData = new BufferedReader(isr); String str; str = inData.readLine(); return (new Double(str)).doubleValue(); } /** * This method demonstrates square(). * @param args Unused. * @return Nothing. * @exception IOException On input error. * @see IOException */ publicstaticvoidmain(String args[])throws IOException { SquareNum ob = new SquareNum(); double val; System.out.println("Enter value to be squared: "); val = ob.getNumber(); val = ob.square(val); System.out.println("Squared value is " + val); } }
C语言
以//开始、以换行符结束的单行注释
1
constdouble pi = 3.1415926536; // pi是—个常量
以/开始、以/结束的块注释
1
intopen( constchar *name, int mode, … /* int permissions */ );