Java basic knowledge byte, javadoc file production, obtain keyboard input, methods, and variable static conditions

Source: Internet
Author: User

1. 1 byte occupies 8 bits (that is, 1 byte occupies 8 bits)

1char occupies 16 bits (that is, 1 character occupies 16 bits)

Boolean only occupies 1 digit

2. Use the javadoc command to generate the javadoc File

Use/in the class /**

*

*/

Before class code, you should add class comments to describe some attributes of the class, such as class name, programmer, programming time, and class encapsulation features,

For example, the annotation before the class can be

/**

* Title: Test class <br> // <br> it indicates that the new line breaks by carriage return, making the generated document interface beautiful. If the @ sign is displayed, the end of the line breaks automatically. <br>

* Description: a simulated engineer's class <br>

* Copyright: (c) 2003 www.baidu.com

* Company: IT people Information Exchange Network <br>

* @ Author liubin // author

* @ Version 1.00 // version

*/

Annotation before Method

/**

* This is a function of the Test class object.

* @ Param name Test // name indicates the parameter Test in the method.

*/

Comments on methods with returned values

/**

*

* @ Return description of the returned value

*/

Next, generate the javadoc annotation file. Assume that the sample program Test. java is stored in the C directory, enter the directory where Test. java is located in the command line window, and then run the following command:

Javadoc-d testdoc-version-author Test. java // Where-d is used to specify the name of the generated folder, that is, the javadoc file to be stored is followed by the version information and author information added to the description document.

For more details about javadoc usage, run javadoc-help in the command line window.

3. in java, you can use the following code to read a number entered from the keyboard.

System. in. read (); // wait for user input when the code is running.

String s = JOptionPane. showInputDialog ("enter a value"); // This line of code will pop up a dialog box prompting the user to input through the keyboard

Enter the following code for the displayed User:

Byte buf [] = new byte (1024 );

System. in. read (buf); =

String string = new String (buf, 0); // convert buf to String object string (that is, convert ASCII to Unicode)

Int keyint = Integer. parseInt (string. trim ());

4. The final keyword is added before constants in java;

5. Static ---- static

Non-static --- static or non-static

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.