Core Java technology data types Chapter III

        Java is a strongly typed language. This means you must declare a type for each variable. In Java, a total of eight basic types, of which four kinds of integer, 2 float, Boolean type for one kind of type char Character Unicode character cell expressing encoded and 1 is used to represent the true value.
3.3.1 Integer
Integer value used to indicate no fractional part, which allows negative. Java provides four integer.
    int 4 bytes
    short 2 bytes
    long 8 bytes
    byte 1 byte
Under normal circumstances, int type most commonly used. long type can be used to represent the content of more than 2 billion. byte short type is mainly used and the particular application, e.g., the underlying file or process control needs a large amount of space occupied by the storage array.
This stuff with them typing something much worse than the word, and can not wrap up and down two rows are not connected. Also playing out ugly.
There is a long integer value L or L suffix (eg 390000000L). A hexadecimal value 0x or 0X (eg 0xCAFE). A prefix octal 0, for example, corresponding to 010 of 8 octets. Obviously, octal confusing, so it would be best not to use octal constant.
Java7 from the beginning, prefixed 0b or 0B can write a binary number. Also Java7 from the beginning, but also that digital literal underlined.
Java does not have any int, long, short and byte type unsigned form. See https://www.cnblogs.com/huzi007/p/6566567.html
3.3.2 Floating Point Types
Floating-point type is used to represent the numerical value of the fractional part. There are two types of floating point in Java.
    float 4 bytes
    double 8 bytes
double float type represents twice the numerical precision of this type (so called double-precision number someone). The vast majority of applications use double. In many cases, float type of accuracy is difficult to meet the demand. In fact only a few cases suitable for use float.
3.3.3 char type
3.4 Variable
3.4.1 variable initialization
3.4.2 Constant
In Java, use the keyword final instructions constants. Keyword final indicates that the variable can only be assigned once. Once assigned, it can not be changed. Traditionally constant name to use all uppercase.
Operators 3.5
Mathematical functions and constants
Conversion between numeric types
Cast
And the assignment operators binding
Increment decrement operators: there are two types of prefixes and suffixes ++ n and n ++. Prefixes and suffixes are in the form of the variable value is incremented or decremented by 1. However, in expressions have two difference.
Prefix form is first completed is incremented; postfix form would use the original value of the variable. (Not recommended for use in the expression ++, because such code is easy to be confusing, but will bring bug annoying)
Boolean operators and the relationship: or non. Ternary operator
Bitwise Operators
And operator-level bracket
Enumerated type
3.6 String
Substring
splice
String immutable
    Detecting whether the string is equal to: detect if two strings are equal using the equals method. s.equals (t); If the string s and t strings are equal, returns true; otherwise returns false. Note that s and t can be a string variable or a string literal. == operator must not detect the two strings are equal. The operator is only able to determine whether the two strings in the same position. Of course, if placed in the same position, they must be equal. It is completely possible that multiple copies of the same content strings are placed in different positions.
    Empty string and the string Null: empty string "" is a string of length zero. The following code can be invoked to check whether a string is empty: if (str.length () == 0) or if (str.equals ( "")) is a Java object empty string, string length has its own (0) and content (empty). However, String variables can also store a special value called null, said they currently no object associated with the variable. To check whether a string is null, to use the following conditions: if (str == null).
    Sometimes to check if a string is neither null nor empty: if (!! Str = null && str.length = 0). Str first thing to check is not null, if you call a method on a null value, an error will occur.
3.6.6 Point Code and code means
    

Guess you like

Origin www.cnblogs.com/sx1011/p/11705909.html