Basic concepts of Java

Source: Internet
Author: User
Tags arithmetic operators bitwise

Basic features of Java

 Java is a relatively simple language, and simplicity has become one of the reasons why Java is growing rapidly.
Java is one of the few multithreaded languages
Java is an object-oriented programming language
Java provides an automated garbage collection mechanism (GC)
Java avoids complex pointer problems, and uses reference to manipulate memory
Java can achieve any platform spanning.

The Java compiler compiles the source file into a bytecode file, which is then handed to Jvm,java's interpreter to interpret the class file on a specific platform.

Path: is a property of the operating system, which is a number of executable (or) program paths.

classpath: The path of the *.class file needs to be loaded when the Java interpreter

Types of data

Java's data types fall into two categories: basic data types and reference data types

  1. Basic data types

                : Byte, short, int, long     default value is 0
                floating-point type: float, double             The default value is 0.0
                character type: char     & nbsp                         The default value is \u0000
                Boolean type: Boolean                       default value is False

  2. Reference data type: Array, class, interface default value is NULL

Basic data types do not involve memory allocation issues, and reference data requires allocating memory space
Indicates that integers use int for decimals to implement date numbers or file size using long
Implementing data passing or encoding using the Boolean description using byte to implement logical control
In the programming world, large-scale data and small-scale data are arithmetic, and small-scale data is automatically converted to a wide range of data for computation.

If a large range of data is to be transformed into a small range of data, then a forced type conversion is used.
* Do not trust the default value because the default value in the method is not valid, so the default value should be given manually in the development

data of type char and int can be converted to each other because each character has an encoding (Unicode), some characters have special meanings in a particular compilation environment,

The escape character is used to remove its special meaning. \f, \b backspace, \ ' single quotation mark, \ t tab, \ \ backslash \ r return, \ ' double quotation mark, \ n line break

Operator
1. Arithmetic Operators
%, + +,--、 =, + 、-、 *,/, + =,-=, *=,/=,%=

2. Logical Operators
            || : Logical OR operation, if the first condition returns TRUE, the second condition is no longer executed
Use "|" Instead of "| |", "|" Can be used as either an operator or as a bitwise operator
&&: Logic and arithmetic, only two conditions return true when the end result is true, otherwise false
Use "&" as a logical and operation, or as a bitwise operator to use
3. Three mesh operator
syntax: condition?value1:value2;
-If condition returns true then the entire Trinocular expression returns value1 (the first value)
-If condition returns false then the entire Trinocular expression returns value2 (second value)
Expression : An expression is an expression that consists of one or more operands coupled with a regular combination of operators, and the expression typically returns a Boolean type value.
Loops
Three types of loops
1.for Cycle
The basic syntax:
For (initialization of variables; condition judgment; updating of variables) {
Loop body
}
Steps:
Initialization of the ① variable
② condition judgment, if the condition is satisfied to execute the loop body, and then into the ③, if the condition is not met, the loop is terminated
③ variable update, enter ②
2.while Cycle
while (condition) {
Loop body (statement that contains a variable update)
}
3.do while loop
do{
Loop body (statement that contains a variable update)
}while (condition);
The difference between a while and a do{}while loop: the latter is executed once regardless of whether the condition is satisfied.
The difference between while and for: the function of the For loop can be completed while loop must be completed, not vice
Choose the For loop when you know the number of loops and select while if you don't know the number of loops.
Use of break, continue, lable keywords
break: When a break is executed, the code behind the break is not executed and the next loop is no longer opened (unless there is an outer loop control) to terminate the entire loop
continue: When executing to continue, the subsequent code will not be executed, but the next loop will be opened, that is, it will only terminate when the secondary loop
break and continue will only be effective in the loop closest to him.
lable Mark jumps out of the loop to the position of the marker.

Basic concepts of Java

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.