Java First week summary

Source: Internet
Author: User
Tags bitwise bitwise operators value of pi java se

Computer language as a tool for communication between human and computer, the earliest computer language is DOS language, also called computer mother tongue, along with the development of computer language, has appeared C language, C + + language and Java language, etc.

The Java language was introduced in 1995 by Sun, with the development of the Java language, there are three branches Java EE (Enterprise Edition), Java SE (Standard Edition), J2ME (small version);

JDK: Java SDK, which provides Java development tools, including JRE, Javac and so on;

JRE: Java operating environment, to ensure that Java in the operation of the PC;

javac; Java compiler tool that compiles the Java language into a program that a virtual machine can recognize and run;

After the JDK installation, you need to configure the computer environment variables, after the configuration is completed using DOS java-version and javac-version in the CMD interface to detect whether the JDK and Jer installed correctly, JDK and Jer version information, to ensure that Java in the development and operation of the PC;

The writing of Java code must be written in a fixed format :

public class Helloword {
public static void Main (String [] args) {
System.out.println ("Helloword");
}
}

public: permission modifier; class: Defines the classes that Java code stores, and the part between two {} is called " domain ";

Public static void Main (String [] args): Defines a Main method (main) as the main entry for running code for a virtual machine;

System.out.println ("Helloword"): After the virtual machine enters the main (main) method, the command computer outputs the instructions to print "Helloword" Each sentence must be followed by a ";" After the code is run.

The basic composition of the J Ava language :

keywords, identifiers, data types, constants and variables, operators, statements, functions, arrays;

Keywords: words that are given special meanings ( keywords are all lowercase ), Common: Boolean, Byte, double, and so on.

identifiers :

The selection of identifiers must follow the following rules :

1. Identifiers cannot be keywords or true, false, null;

2. Identifiers can contain letters, numbers 0-9, underscores (-), or dollar signs ($);

3. The first character of the identifier must be a letter, an underscore (-), or a dollar sign ($);

4. Identifiers are case-sensitive and do not specify the maximum length;

Example: Public, $change, userName1, and so on.

data type : Divided into basic types and reference types ;

The basic types are: integer (such as int), float (such as float), character type (such as Char), and Boolean (Boolean);

variables: variables are used to store data ; A variable must first declare a small amount of memory in memory for storing data;

int number;// declares an integer variable named number and declares a memory space in memory called number

number=1;//assigns the value "1" to the variable number, which means that the data "1" is stored in the memory space

constant : Use final to fix the value of a variable to prevent the user from changing it;

The value of the final double pi=3.1415926;//pi is pi, and when the pi is declared constant, the value of pi is unchanged at any time when itis called in the whole program .

operator : a symbol that implements certain functions in code; the increment (+ +) and decrement (--) operators are prefixed with " self-increment (minus), then apply ", instead, as suffix is " first use , after self-increase (minus)";

bitwise Operators "&", "|", "^":

"&" (Bitwise AND) 0101&1011=1111=15;

| (bitwise OR) 0101|1011=0001=1;

"^" (bitwise XOR) 0101^1011=1110=14;

Program Flow control : Select, loop, call method (function);

Boolean logic is the distinction between " and ", " or ", "or", " non ", mainly using Ubourg operators, such as & and & the difference between the &, when the first Boolean expression is False,,&& will short , so-called short-circuit is the current expression

For false,& will continue to judge the latter expression, and && will skip the second expression, directly return false; (a>0) & (A<1 ) when (a>0) ,& will continue to judge (A<1) for false, while using

&&:(a>0) && (a<1) when (a>0) is False,&& will return the result directly false, no longer the Judgment (a<1);

SELECT statement:

If statement :if (Boolean expression) {

If the Boolean expression returns the result to True (true), execute the statement here

}

if/else Statement :if (Boolean expression) {

}else if (Boolean expression) {

}

else if (Boolean expression) {

}//.... In the middle you can add the else if if until the last one is else, and when the first if returns false, jump to the next if, until you meet an if to execute the statement there, and if it is not true at the end, On the implementation

The last one in the else statement

else{

}

switch statement :switch (variable) {

Case Value:

EXECUTE statement

Case Value:

EXECUTE statement

There is no limit to the number of cases, and when the value of a variable in a switch matches the value of one of the case, the statement under the current box is executed. If there is no matching case "value" at the end, execute the last default

The statement

Default

EXECUTE statement

}

Loop Statement :

For statement : for(initialize; Boolean expression; update) {

Statement

Executes the statement once after initialization, then returns the Boolean expression, if the result is true, executes the statement again , if false, jumps out for the FOR Loop statement, after execution, returns the UPDATE statement, and then to the cloth

The expression is judged, so loop

}

Break and Continue statements : Break skips the entire loop body , while continue jumps out of the loop to continue the loop in the next iteration

Java First week summary

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.