Getting Started with Java (type conversion, string manipulation, etc.)

Source: Internet
Author: User
Tags arithmetic operators bitwise operators

Java basic data type: cannot =null;
Four types of eight types:

Integer type:

BYTE 2 of the 8-time Square

Short 2 of the 16-time Square
int 2 of the 32-time Square

Long 2 of the 64-time Square

Floating point type:
Float
Double
Boolean type:
Boolean (only two values, true, false)
Character type:
Char
String:
String

Type conversions:
Implicit conversions (we don't see the conversion process);
Conditions:
From low-precision to high-precision conversion;
Double 16-bit 1.222222222

Float 8-bit 1.2222222 total eight-bit
Double > Float > Long > int > Short > Byte
An explicit conversion:
Long A = 5;
int L = (int) A; Forced conversions

String manipulation:
String str1 = ""; Reference type
String str = new String ("");
IndexOf (""): the first occurrence of the position, index value
LastIndexOf: Last occurrence of position, index value
CharAt: Index
SUBSTRING (5): Intercept strings from 5 onwards
SUBSTRING (2,4): Starting from 2 to 3, excluding 4
Trim (): Only the front and the last space are removed, the middle is no matter
Replace (', '): Can be a character, can be a string, replace the front one with the back one, the string is ""
ReplaceAll ("", ""):
Equals (): Determines whether two strings are equal (S1,equals (S2));
Split (","): String split
toUpperCase (): Convert uppercase

Flow Control Branch Loop statement
If.....else
If.....else If....else

Switch (value 0) {//value 0 is what type, the following value is what type
Case value 1:
Execute the statement;
Break
Default
Execute the statement;
Break
}

while (condition) {
}do{}while ()

for (initial value; condition judgment; Initial value change) {
}
for (int a: array (int)) {
}


Operator:
Arithmetic operators: +-*/% + +--
Relational operators:> < >= <= = = =!
Logical operator:! & && | | | ^
Bitwise operators:>> << >>> (unsigned Right shift)
Assignment operator: = = = = *=/=%=
String Join Operator: + (in the output, as long as one parameter is a string, the entire output is a string)
Ternary operator: Boolean value 1: Value 2

Getting Started with Java (type conversion, string manipulation, etc.)

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.