The basic concept of Java Basics for Dark Horse programmers

Source: Internet
Author: User
Tags arithmetic operators case statement

1. What is programming?

Programming is the process of having a computer write program code in a programming language to solve a problem and ultimately get results.

In order to make the computer understand human's intention, human beings must tell the computer in the form of the computer can understand the problem of the idea, method, and means, so that the computer can work according to the instructions of the people, and accomplish a certain task. The process of communication between people and computers is programming.

2. Java language overview, history, features

is a high-level language introduced by Sun (Stanford University Network, Stanford University web Company) in 1995. is an Internet-facing programming language.

As Java technology continues to mature in the web, it has become the preferred development language for Web applications. Is easy to learn, completely object-oriented, safe and reliable, platform-independent programming language.

Three technical frameworks after the Java5.0

EE (Java 2 Platform Enterprise Edition) Corporate Edition

Called Java EE after the jdk5.0 version, is a set of solutions for developing applications in enterprise environments. The technologies included in the system, such as Servlet JSPs, are primarily targeted at web application development.

J2SE (Java 2 Platform standard Edition) edition

After the jdk5.0 version is called Javase, which is the main learning content in the basic stage, but also the foundation of Java, whether it is the development of Android or the internet of Things + cloud computing is based on Javase, once the technology is the core of Java technology, It is the main course content of the basic course of Intelligence podcast.

J2ME (Java 2 plaformt micro Edition) Mini version

After the jdk5.0 version is called the Javame, this technology is applied to some electronic products embedded development, previously used in mobile phone development is also more, but with the development of smartphones, now mobile applications (such as Android program) development has no longer use the technology.

3. What is cross-platform? What is the principle? Jvm

The so-called cross-platform, refers to the Java language program written, once compiled, can be run on multiple system platforms.

Implementation principle: Java program is running on the system platform through the Java Virtual machine, as long as the system can install the corresponding Java virtual machine, the system can run Java programs. (Note: It is not possible to run on all platforms, the key is whether the platform can install the corresponding virtual machine).

The difference between 4.Jre and JDK

Jre: (Java Runtime Environment), Java Runtime Environment. Includes the Java Virtual machine (JVM Java) and the core class libraries required by the Java program. If you want to run a well-developed Java program, your computer will just install the JRE.

JDK: (Java Development Kit Java) Development Kit, JDK is to provide Seijava developer, which contains Java development tools, also includes the JRE, so install the JDK, there is no need to install the JRE;

One of the development tools: Compilation Tool: Javac.exe

Packaging Tool: Jar.exe

In simple terms: Java programs developed using the JDK are delivered to the JRE to run

5.java Virtual Machine

Java virtual machine, abbreviated JVM

It is an abstract computer that runs all Java programs, is the Java language's operating environment, it is one of the most attractive features of Java, the JVM reads and processes the compiler through the platform-independent bytecode (class) file.

The Java compiler generates a class file for the JVM and is therefore platform independent;

The Java interpreter is responsible for running the JVM's code on a specific platform;

Java virtual machines are non-cross-platform;

6.java program operating mechanism

Compile: Javac file name. filename Suffix Name

Run: Java class name

7.java Places to watch

The Java language is strictly case-sensitive in spelling

A Java source file can define multiple Java classes, but there can be at most one of the classes defined as a public class;

If the source file contains the public class, the source file must have the same name as the public class;

When a source file contains many Java classes, it generates many copies of the bytecode file, i.e. each class generates a separate class file, and the byte-code file name and its corresponding class name are the same;

Summary: Only one class is defined in a Java source file, and different classes use different source file definitions;

Define the individually defined classes in each source file as public;

Keep the main file name of the Java source files consistent with the class name of the source file;

8.java syntax format

Any language has its own grammatical rules. Java is the same, since it is the rule, then know how to use it.

The code is defined in the class, the class is defined by class, and the public class and class are distinguished.

The function of the Main method:

The entry of the program to ensure that the program runs independently and is called by the JVM

9. Code Comment: Single line//Multiple lines/* */Document Comment/***/

Single-line comments//After all characters ending with the bank are ignored by the compiler

All characters between the multiline comment/* * * are ignored by the compiler

All characters between document comment/***/are ignored by the compiler, Java-specific, used to generate documents

Identifiers in 10.java

It can be simply understood as: a name that is customized for readability in a Java program, such as: Class name, method name, variable name, etc.

Naming rules: (1) by the letter (can be Chinese, foreign language), underline, $ composition, can not start with a number;

(2) Case sensitive;

(3) You cannot use keywords and reserved words in Java;

(4) Do not use the class name in the Java API as your own.

Variables and constants in 11.java

The concept of variables: Occupy an area of memory, the region has its own name (variable name) and type (data type);

The data in this area can be constantly changed within the same type.

Why define variables: used to keep constant of the same type, and can be reused.

Use variables to note: The scope and initialization values of variables.

To define the format of a variable:

Variable name of data type = initialization value;

Note: The format is fixed.

Scope: The end of the code block from the definition start to the definition of it.

Multiple local variable naming conflicts are not allowed in the same scope.

Local variables and member variables in 12:java:

Local variables: Variables that are declared in the method body of a class, must be initialized before local variables are used, local variables have no default initialization values, and local variables are scoped from the beginning of the definition to the end of the code block that defines it;

Member variables: In the body of the method, variables declared in the class, also known as field or global variables; (there is no global variable in Java, because Java is an object-oriented language, all variables are class members)

The scope of the member variable is in the entire class;

13. Basic Data types

In the data type, the most commonly used is the most basic data type, known as the base data type. These types of values can be used to represent some simple states;

There are 4 classes and 8 types of basic data types in the Java language:

Integer: Byte-byte, short, int, long-integer

Decimal type: Float single-precision floating-point, double double-precision floating-point type

Character type: char character type

Boolean Type: Boolean Boolean

Fixed-point type: An integer is a class of types that represent integer values. When it is necessary to represent the value of an integer, you can choose from four types according to need, if there is no special requirements, the general choice of int, the main difference of 4 types of integers mainly in each data memory occupies the space size and the value of the range of the representative;

Floating-point type: Decimal type is a class of types that represent small values. When the need to represent a decimal value, you can choose from two types according to the appropriate, if there is no special requirements, the general choice of double type;

Because decimals are stored in different ways than integers, decimals have a certain precision, so they are not accurate in computing. Two decimal types are designed, depending on the accuracy and storage interval:

Single-precision floating-point type: Float, takes up 4 bytes of space

Double-precision floating-point type: Double, takes up 8 bytes of space

Character type: The character type represents a specific character, the computer is a character set to save characters, so the value of the character type is actually a character set in the number, rather than the actual character represented by the computer to complete the work from the number to the corresponding character, the Java language in order to more convenient internationalization, Uses the Unicode character set as the default character set, which contains characters that are common in various languages. In program code, characters are identified by using a pair of single quotes plus characters that need to be expressed, or they can be represented by a character encoding, which is a non-negative integer. A char type occupies 2 bytes of space.

Boolean: Representing the logic of the establishment and the non-establishment of the Java language using the keyword true for the establishment, false is not tenable, Boolean is the type of storage logic value, in fact, many programs have the concept of logical values, Java to the logical value of the Boolean type to express, the Boolean type occupies 1 bytes of space.

14. Basic data type up and down conversion

Upward conversion: integer, character, floating point data are converted to each other in a mixed operation, and the conversion follows the following principles: small-capacity types can be automatically converted to large-capacity data types (also known as implicit conversions);

Byte,short,char>long>double

Byte,short,char do not convert to each other, they are first converted to int type when calculating.

The Boolean type cannot be converted to another base data type.

Down conversions: integers, character types, floating-point data are converted to and from each other in mixed operations, and the following principles are followed when converting:

Large-capacity types must be strongly turned (also known as explicit type conversions) to convert to small capacity types

Operators for 15.java

An operator is a special symbol that represents the operation, assignment, and comparison of data.

Divided into: arithmetic operators: +-*/%

Assignment relationship: = + = = *=/=%=

Relational operators:< > <= >=! =

Conditional operator:& && |  ||  ! ^

Bitwise operator:& | ^ ~ << >> <<< >>>

Summary:& and &&: But with, both sides are involved in the operation, double and when, if the left is true, the right to participate in the operation; if the left is false, the right does not participate in the operation;

|  and | | : Single or time, both sides are involved in the operation;

Double or time, if the left is true, the right does not participate in the operation;

^: When the left and right are the same, false, when the left and right are not simultaneous, for true;

16. Expressions and three-mesh operators

is a sequence of meaningful permutations of numbers, operators, numbers, and so on, in order to be able to derive values;

The type and value of an expression: the result of an operand in an expression is the value of an expression;

The data type of an expression is the type of an expression;

The order of operation of the expression: the order of precedence of the operator should be from high to low;

Operators with the same precedence are performed in a pre-agreed binding direction.

Syntax format for the trinocular operator:

X? Y:z;

where x is a Boolean expression, the value of x is evaluated first, and if true, the result of the entire trinocular operator is the value of the expression Y, otherwise it is the value of Z.

17. Process Control Statements

Circular structure of sequential structure branching structure control loop structure

Sequential structure: If there is no process control in the code, the program is first and the next line is executed, and the next line of statements executes until the end of the program.

If statement:

Basic syntax: if (expression) {method body}else if (expression) {method body}else{method Body}

Three different formats:

(1) if (conditional expression) {EXECUTE statement;}

(2) if (conditional expression) {EXECUTE statement;}else{EXECUTE statement;}

(3) if (conditional expression) {EXECUTE statement;}else if (conditional expression) {EXECUTE statement;}......else{EXECUTE statement;}

Switch Control statement:

Format:

Switch (expression)

{

Possible result of CASE expression 1:

Execute the statement;

Break

Possible result of CASE Expression 2:

Execute the statement;

Break

......

Default

Execute the statement;

Break

}

Note: There is no order between case and default.

There are two ways to end the switch statement: The end of execution of the Break,switch statement is encountered. If the matching case or default does not have a corresponding default, then the program proceeds from the first match with a case statement and runs the statement that can run until the break or switch ends. The penetrating nature of the--switch statement

The switch statement can only use Byte, char, short, int, four basic types, and their wrapper classes and enumerations

18. Three Cycle structures

Used to handle operations that require repeated execution;

Depending on whether the condition is established or not, the number of executions of the procedure is determined, and this procedure is referred to as the loop body;

While you do not know how many times the loop executes

Do-while implementations do not know how many times to execute, at least once (limit once, then judge)

For need to know the number of loops

While format

while (conditional expression value is true)

{

Execute the statement;

}

Do While statement format:

Do

{

Execute the statement;

}

while (conditional expression is true);

The conditional expression in the loop cannot directly write false or directly write an expression that evaluates to False, but you can use a variable to pass a false value.

For loop structure

Format:

For (initialization expression (1), loop-conditional expression (2), post-loop action expression (3))

{

Execution statement; (4)

}

Order of Execution: (1) (4) (2) (3)

Note: (1) The Order of the 3 expressions in the For loop, the initialization expression is read only once, the loop condition is judged, the loop body is executed for the real, then the operation expression after the loop is executed, then the loop condition is continued to be judged, and a process is repeatedly found until the condition is not satisfied.

(2) While and for can be interchanged, the difference is that the variable defined for the loop is freed in memory after the for loop, while the variable used by the while loop can continue to be used after the loop ends.

(3) The simplest infinite loop format: while (true), the infinite loop exists because it does not know how many times the loop is, but instead controls the loop based on certain conditions.

19. Nested Loops and Process Control

Nested loops: Loops inside the loop;

Assuming that the number of cycles in the outer loop is M, and that the inner loop is n times, the total number of cycles in the inner loop needs to be m*n times

Process Control

Break statement, continue statement

Break terminates the layer loop

Continue skip this layer loop

Note: (1) If these two statements leave the scope of application, there is no meaning;

(2) Both statements cannot have statements behind them, because they cannot be executed;

(3) Continue statement is to jump out of this cycle, continue the next cycle;

(4) The appearance of the label allows the two statements to function on the specified loop;

The basic concept of Java Basics for Dark Horse programmers

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.