Java How to write annotations __java

Source: Internet
Author: User
Tags getdate
Entire class file annotation

Examples are as follows:

/*

* @ (#) Object.java 1.61 03/01/23

*

* Copyright 2003 Sun Microsystems, Inc. All rights reserved.

* SUN proprietary/confidential. Use are subject to license terms.

*/

Package Java.lang;

Annotation structure:

/*

* @ (#) {class name}.java {creation time}

*

* {A person or company has complete copyright}

* {The user must pass the license}

*/

Package Java.lang;

2. Specific class function annotation

Examples are as follows:

/**

* Class <code>Object</code> is the root of the class hierarchy.

* Every class has <code>Object</code> as a superclass. All objects,

* including arrays, implement the methods of this class.

*

* @author unascribed

* @version 1.61, 01/23/03

* @see Java.lang.Class

* @since JDK1.0

*/

public class Object {}

Annotation structure:

/**

* Class <code>{class name}</code>{This kind of function description}

*

* @author {Author}

* @version {version, commonly used time instead}

* @see Java.lang.Class

* @since JDK{JDK version}

*/

public class Object {}

3. Class variable annotation

Examples are as follows:

/** The value is used for character storage. */

Private Char value[];

Annotation structure:

/** {This value is used to store/record what}*/

Private String str;

4. Class method Annotation

Examples are as follows:

/**

* Returns A new string, is a substring of this string. The

* SUBSTRING begins with the character at the specified index and

* Extends to the "end of" this string. <p>

* Examples:

* <blockquote><pre>

* "Unhappy". SUBSTRING (2) returns "Happy"

* "Harbison". SUBSTRING (3) returns "Bison"

* "Emptiness". SUBSTRING (9) returns "" (An empty string)

* </pre></blockquote>

*

* @param beginindex the beginning index, inclusive.

* @return the specified substring.

* @exception Indexoutofboundsexception if

* <code>beginIndex</code> is negative or larger than the

* Length of this <code>String</code> object.

*/

Public String substring (int beginindex) {

return substring (beginindex, count);

}

Annotation structure:

/**

* {The function/action description of the method}

*

* @param {introduce parameter name} {introduce parameters description}

* @return {return parameter name} {return argument description}

* @exception {Indicate what exceptions will occur in a situation}

*/

Public String substring (int beginindex) {

return substring (beginindex, count);

}

5. code block annotation in class method

Examples are as follows:

/*

* Call the Persistence class to save the data to the library

*

* To determine whether to add, or modify

*/

Boolean ifsucc = false;

if (Request.getparameter ("yingli_id") ==null) {

String GUID = new Randomguid (). toString ();

STRESSTESTDATABEAN.SETUSER_ID (integer.tostring (userId));

STRESSTESTDATABEAN.SETSIGN_ISBN ((String) vsectnum.get (0));

Stresstestdatabean.setshenhe_jieguo ("0");

Stresstestdatabean.setguid (GUID);

Stresstestdatabean.setcreate_date ("getdate ()");

Stresstestdatabean.setstate ("A");

IFSUCC = Stresstestdatadao.addstresstestdata (Db,stresstestdatabean);

}else{

IFSUCC = Stresstestdatadao.mendstresstestdata (Db,stresstestdatabean);

}

Annotation structure:

/*

* {Feature Description}

*

* {Specific implementation action}

*/

Boolean ifsucc = false;

if (Request.getparameter ("yingli_id") ==null) {

String GUID = new Randomguid (). toString ();

STRESSTESTDATABEAN.SETUSER_ID (integer.tostring (userId));

STRESSTESTDATABEAN.SETSIGN_ISBN ((String) vsectnum.get (0));

Stresstestdatabean.setshenhe_jieguo ("0");

Stresstestdatabean.setguid (GUID);

Stresstestdatabean.setcreate_date ("getdate ()");

Stresstestdatabean.setstate ("A");

IFSUCC = Stresstestdatadao.addstresstestdata (Db,stresstestdatabean);

}else{

IFSUCC = Stresstestdatadao.mendstresstestdata (Db,stresstestdatabean);

}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.