Java Learning notes 4--identifiers, constants, variables

Source: Internet
Author: User

One, the identifiers in Java must follow the following rules:

1. Cannot start with a number

2. Cannot use keywords

3, in the custom Java identifier should be aware that Java is strictly case-sensitive , in order to improve the readability, to use meaningful identifiers as far as possible

Second, the name specification in Java:
? Package Name: All letters are lowercase when multiple words are composed.
xxxyyyzzz
? Class Name Interface name: When multiple words are composed, the first letter of all words is capitalized.
xxxyyyzzz
? variable name and function name: When multiple words are composed, the first letter is lowercase, and the second word starts with the first letter of each word capitalized.
xxxyyyzzz
? constant Name: all letters are capitalized. For multiple words, each word is connected with an underscore.
xxx_yyy_zzz

Third, comments in Java

1. Single-line Comment
Format:// Comment text
2, multi-line Comment
Format:/* Comment text * /
3. Documentation Comments
Format:/**

Comment Text

*/

Note:

Single-line comments and multiline comments are not interpreted by the JVM, which is a Java-specific comment that can be parsed by Javadoc in the JDK to generate a set of web
A document that describes the program in the form of a page file.

Iv. Constants in Java (fixed values)

1, integer constant. All integers, shown in Java as decimal, octal (0), 16 binary, etc. (0x)
2, decimal constant. All decimals
3, Boolean constant. More unique, only two values. True false.
4, character constant. A numeric letter or symbol is identified by a single quotation mark (' '). such as ' a '
5, string constant. Identifies one or more characters in double quotation marks (""). such as "AB"
6, NULL constant. There is only one value: null

V. Conversion of the binary system

Conversion methods for each of the conversions: convert all into binary and then convert to the binary to be converted into

The binary representation of negative numbers is the inverse plus 1 for the corresponding positive binary.

For example: Decimal 6 and-6

6 occupies 4 bytes in memory, representing the form: 0000-0000 0000-0000 0000-0000 0000-0110

-6 of the expressions are: 1111-1111 1111-1111 1111-1111 1111-1010

can be calculated using Java programs:

class vardemo{        publicstaticvoid  main (string[] args)        {                System.out.println (Integer.tobinarystring (-6));                System.out.println (0x3c);        }}

The result of the operation is:

11111111111111111111111111111010

60

Using the above procedure to calculate the different positive and negative numbers can be concluded: Negative binary highest bit is 1

Vi. variables

Variables are the storage of uncertain data, that is, the need to open a space in memory

Java Learning notes 4--identifiers, constants, variables

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.