Java Basic syntax

Source: Internet
Author: User

One: cross-line

Java variables cannot span rows, such as: String NA

me = "Zhang San";

String cannot span rows, such as: string a = "xxxxxxxxxx

Yyyyyyyy ";

Two: identifier rules

Java identifiers are named variables, classes, methods, and so on. The Java language is strictly case-sensitive. Identifiers can consist of letters, numbers, underscores, and dollar ($) characters, where numbers cannot begin. Identifiers cannot contain spaces.

  

Three: Data type classification

The types supported by the Java language are divided into two categories: the base type and the reference type.

Basic type:

    • Boolean type:
    • Numeric type: integer type (byte, short, int, long, char), floating-point type (float, double)

Reference type: Class, interface, array, NULL type

Four: note several types

The Java integer default is the int type, for example: byte a = 56; (The system assigns 56 to a byte variable), long bigvalue = 9999999999999999; (at this point the system is not assigned to the long variable, but assigns the value to the INT variable, Because the storage can not be error), only such storage long bigvalue = 999999999999999L;

The Unicode character set used by the Java language is encoded as a char character variable in Java that is a 16-bit unsigned integer that differs from the 8-bit char in the C language.

The Java language floating-point type is the double type by default, and if you want to treat a floating-point value as a float type, you should write float f = 5.12f;

The Java language also provides 3 special floating-point values: Positive infinity (positive_infinity), negative non-empty large (negative_infinity), non-numeric (NaN), a positive number divided by 0 to get positive infinity, a negative value divided by 0 will get negative infinity, 0.0 divided by 0.0 or to a negative number will get a non-numeric.

V: New features in Java 7

Add a binary integer, denoted by 0B, if the binary number has 32 bits then the highest point represents the sign bit, such as int val = 0b10000000000000000000000000000011; the highest bit is the sign bit. A negative number is 1, negative is the complement of the store, to be converted into the original code to see its value. If you want to represent a 64-bit binary, then add L or L after the binary;

The underscore feature is used in the new values in Java 7, such as: double pi = 3.14_15_92_65_36;

Java Basic syntax

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.