Java Base Identifier

Source: Internet
Author: User
Tags bitwise bitwise operators logical operators

Identifier: The name of the class, method, or variable that the programmer defines for itself.
Identifiers consist of uppercase letters, numbers, underscores (_), and dollar signs, but cannot begin with a number.
Strictly case-sensitive in the Java language.
Package Name: Use lowercase letters.
Class name and Interface name: typically defined as a word consisting of words with meaning, capitalized on the first letter of all words.
Method Name: Usually also consists of words with meaning, the first letter lowercase, and the first letter of the other words are capitalized.
Variable name: member variables and methods are the same, local variables all use lowercase.
Constant name: All uppercase, and the last underlined word
Key words:
1. Access modifier keywords.
Public: The decorated classes, methods, and variables are common, and other classes can access the keyword-decorated class, method, or variable.
Protected: Used to modify methods and variables that can be accessed by classes or subclasses in the same package.
Private: Also modifies methods and variables, methods and variables that can only be accessed by the class in which they are located.
2. Class, method, and variable modifier keywords.
Class: Tells the system that the word that follows is a class name, and thus the top class name.
Interface: Tells the word behind the system to be an interface name, which defines an interface.
Implements: Let the class implement the interface.
Extends: for inheritance.
Abstract: Abstraction modifier.
NEW: Instantiates the object.
3. Process Control Keywords
Process Control statements include If-else Switch-case-default, for Do-while, break, continue
Ruturn instanceof keyword used to determine whether an object is an instance of a class or interface.
4. Exception Handling Keywords
The basic structure of exception handling is try-catch-finally, the three words are keywords, exception handling also includes
Throw and throws of the two keywords. The Assert keyword is used in an assertion operation and is considered an exception handling.
5. Package Control Keywords
The package control keyword is only two, which is the import and Package,inport keywords used to package or class
Import into the program; the Pachage keyword is used to define the package and define the class to the package.
6. Data class Keywords
8 Basic data Types, Boolean (Boolean), character type (char), character type (byte), outer
Numeric type, divided into short int long, Flort double.
7. Special types and Method keywords
The Super keyword is used to refer to the parent class, and the This keyword is used to apply the current class object.
The void keyword is used to define a generic method that does not have any return value.
8. Keywords that are not used.
In the keyword family There are two alternative, const and Goto in front of the known keyword is the system
But these two classes are keywords, but they are not used in the system.
All of the keywords are lowercase, and if capitalized, they are definitely not keywords.
Comments:
Single-line Comment: (//)
Multiline Comment: (/**/)
Document Comments (/** */)

Integer type:
The integer type can be divided into 4 different types depending on the amount of memory space occupied:
BYTE (byte) digit 8 value range-2 (7) to (7) 1
Short 16 Value range-2 (15) to (15) 1
int (integer) digit 32 value range-2 (31) to (31) 1
Long (length) digit 34 value range-2 (63) to (63) 1
Floating-point types:
Floating-point types are divided into
Single-precision floating-point type: Number of digits: 32 value range 1.4e-45~ 3.4e+38
Double-precision floating-point type: Number of digits: 64 value range 4.9e-325~ 1.7e+308
The default is double-precision floating-point types
When using single-precision floating-point types, you must follow the numbers with F or f
In double-precision floating-point types, you can use D or D as a suffix.
Character types are used to store character data types.
Can be defined directly, or it can be defined using Unicode encoding.
Part of the translator in Java
\ ' single quotation mark \ ' double quotation mark \ \ Slash \ r Enter
\ n wrap \f page \ t jump \b backspace

Data type conversions
Java is a strong data class language.
Automatic type conversion:
Automatic data type conversions, data types are compatible, and the preceding data types have fewer digits than
The data type that follows.
A low number of bits can be converted to a high number of digits.
Forcing type conversions
The data types that can be converted from low to high preconditions must be compatible, forcing type conversions
There is a fixed grammar. (type) value
public class qingzhizhuanhuan{
public static void Main (string[] args) {
int i1= 123; Define an int type
byte b= (byte) i1; Force type conversion to byte
System.out.printIn ("int coercion type converts byte after value equals" + B)
}
}
Converting from high image to low, data loss is lost. The maximum value for the byte range is 127.
When floating-point numbers are cast to integers, small amounts of data are also lost in this case.
Implicitly enforcing type conversions
The default type of an integer is int
byte B = 123;
In this code, 123 of this data is of type int, and the defined B variable is byte type and is automatically completed by the Java system.
Arithmetic conforms to an expression
The arithmetic operator is the operator for the calculation including addition (+), minus (-), multiplication (*), and (/) operation remainder (%)
Self-increment self-subtraction operation
The self-increment decrement operator can be considered a special operator, and the increment operator indicates that the operand is incremented by 1.
The decrement operator indicates that the operand is incremented by minus 1;
public class Zizengjian {
public static void Main (string[] args) {
int a = 3;
int b = ++a;
int c = 3;
int d=--c;
System.out.printIn ("The value after the self-increment operation equals" +b);
System.out.printIn ("The value after the self-increment operation equals" +d);
}
}
}
Relational operators
The relational operator is used for biting a relationship between two operands, and the result is a Boolean type.
Relational operator equals (= = =), not equal to (! =), greater than (>), greater than or equal to (>=)
Less than (<) and less than Equals (<=)
Bitwise operators
With (&): If the corresponding bit is 1, the result is 1, otherwise 0;
or (|): If the corresponding bit is 0, the result is 0, otherwise 1.
XOR (^) if the corresponding values are the same, the result is 0, otherwise 1.
Non (~):: Reverse Each bitwise of the operand.
Displacement operator
Left shift operator
The left shift operator is used to move the bits of the first operand to the left of the second operand, and the left vacancy is supplemented with 0 bits.
  
Right shift operator
The left-shift operator is used to move the bits of the first operand to the right by the number of bits specified by the second operand, the first in the binary to indicate positive or negative, 0 for positive, and 1 for the Vice.

Unsigned Right shift operation
The rules for unsigned right-shift and right-shift operators are the same, except that when filling, whether positive or negative, use the zero fill.

logical operators
A logical operator is evaluated with an expression for a numeric value that produces a Boolean type, and the result is a Boolean type, which can be divided into two main classes, one short and non-shorted.
      
Non-short-circuit logical operators
Non-short-circuit logical operators include (&), or (|) and non-(!). The logical operator indicates that the result is true if the operands on both sides of the operation are true, otherwise false.

Short-circuit logical operators
When two operations are true, the result is true if the first action is false, the result must be false, and there is no need to judge the second one.

Ternary operators
There is a special ternary operator in Java that supports conditional expressions that can be used to override when conditional judgments are required
The If-else statement. Expression? Statement:statement2
Highest priority level
()   []  .
+ +--~!
*  /  %
+
>> >>> <<

> >= < <=
= = =
&
^
|
&&

||
? :
= + = = *=
Lowest priority level

Java Base Identifier

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.