Self-study java-data types

Source: Internet
Author: User

1. Keywords:

Keywords (about 50 +) words are lowercase letters.


Goto, const is reserved keyword, not used.



2. Identifiers:

Identifiers are tokens that name a class, interface, method, or variable.


Composition rules, English uppercase and lowercase letters, numeric characters, $ and _, a total of 3 points.


Note that you cannot start with a number, cannot be a Java keyword, and is case-sensitive.


Common naming conventions, see Names,

packages, which are actually folders, are used to differentiate the same class names,

Class or interface, a word, capitalize the first letter of the word, multiple words, capitalize the first letter of each word,

method or variable, one word, first letter lowercase, multiple words, starting with the first letter of the second word,

Constants, one word, all uppercase, multiple words, each word capitalized and separated by an underscore (_).



3. Notes:

Comments are used to interpret the text in the description program.


Java Annotation Classification format, single-line Comments (//), Multi-line Comments (/*/) can not be nested use, document Comments (by the Javadoc tool to explain the instructions), a total of 3.


Beginners should write comments (ideas), and then write code, code is the embodiment of thought.



4. Constants:

A constant is a value that cannot be changed during program execution.


Java constant classification, literal constants (string constants, integer constants, floating-point constants, character constants, Boolean constants, NULL constants, NULL), custom constants, total 2 classes.


Binary, is a carry mode, X-Input, every x into 1.


Java Integer constants 4 representations of binary (0, 1, 0b), octal (0~7, 0), decimal (default), hexadecimal (0~f/f), 0x.


Binary conversion, 2 of 1 to 10 powers to be known, 10/binary Fast Conversion mode (8421BCD code), X-Binary to Y-decimal to do the bridge (x-binary-decimal-y-binary).


There are 3 types of symbolic data representations,

The original code, the highest bit is the sign bit, 0 table positive, 1 table negative, the remaining bit table value size,

Inverse code, negative number of the inverse code is to its original code bitwise negation, except the sign bit,

complement, integer complement = original code, negative complement is its inverse code of the bottom plus 1.


The operation of the data in the computer is in the complement, the person sees the original code, and the memory operation's complement.



5. Data type:

Java is a strongly typed language that defines a specific data type for each data and allocates a different size of memory space in memory.


Data types are divided into 2 classes, basic data types (numeric (integer, floating-point type), character, Boolean), reference data type (class, interface, array).


Integers, Byte (1 bytes), short (2 bytes), int (4 bytes), Long (8 bytes 10....0L),

Floating point number, float (4 byte 12.35F), double (8 bytes),

Character, char (2 bytes),

Boolean, Boolean (1 bytes).


integers are type int by default, and floating-point numbers are type double by default.


Considerations for using variables, scope problems (where variables are defined in curly braces), initialization values (variables that are not initialized are not directly used), it is recommended that a single row define only one variable.


The Boolean type cannot be converted to another data type.


The default conversion (small to large conversion), Byte, short, char + int + long + float + double,byte, short, char are not converted to each other, they participate in the operation first converted to the int type.


Casts, from large data types to small data types, can have a precision loss problem with arbitrary casts.


Addition (+) for the use of variables, the addition will be the first direct type promotion,

The constant is to calculate the result first, and then see whether in a small range, if there is no error.


The string join (+) result is a string type, not an addition operation.


The ASCII code table is obtained by adding a character and an integer, ' A ' 97, ' a ' 65, ' 0 ' 48.



This article from "Xiaozhuan 2016" blog, declined reprint!

Self-study java-data types

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.