Configure temporary environment variables
In real-world development, sometimes the JDK version of the information is sometimes used only once or a few times no longer used, through the SET command to configure temporary environment variables.
Temporary environment variables are only available for the current console window, and once the window is closed, the configured temporary environment variable information disappears.
Use of the SET command:
Set to view all environment variable information.
The name of the set environment variable to view the specified environment variable information.
Set environment variable name = path information sets the specified environment variable information.
Set environment variable name = Empty the specified environment variable information.
Set environment variable name = new Path;% environment variable name% Add new path information based on the original.
Note: In the future, everyone sees the environment variable information set by the SET command, which is the temporary environment variable information.
Identifiers and Keywords
/*identifiers: Some of the names in Java programs can be customized, so these custom names are referred to as custom identifiers. Identifiers to note the details: 1. The constituent elements of an identifier are the letters (A-ZA-Z), the number (0-9), the underscore (_), the dollar sign ($). 2. Identifiers cannot begin with a number. 3. Identifiers are strictly case-sensitive. 4. The length of the identifier is not limited in length. 5. The designation of identifiers is generally meaningful (see name) 6. keywords, reserved words cannot be used for custom identifiers. Specification for custom identifiers: 1. The first letter of the class name and interface list Word is capitalized, and the other words are lowercase. For example: RunTime. 2. Variable name and method name the first word all lowercase, other words first uppercase, other lowercase. For example: Docook (); 3. Package name all words lowercase. 4. Constant all the words are capitalized, and the words are separated from the words using an underscore. For example: Up_direction judge those identifiers that are compliant: 12ABC_ illegal numbers can not start _12abc legal $ab 12# illegal #号不属于标识符组成元素. [Email protected] Illegal @ does not belong to the identifier component element. Keywords: keywords are identifiers that have special meanings in Java programs. Keywords are typically used to describe the structure of a program or to represent a data type. */classdemo1{ Public Static voidMain (string[] args) {System.out.println ("Hello world!"); }}Comments
/*Note: A note is a description of the program using text, which is written to the programmer, and the compiler ignores the contents of the comment. Categories of annotations: first: Single-line comments. The second type of comment: Multiple lines of comment. /* Content of comments*//*The third type: Document comments. /** the contents of a comment*//*A document comment is also a multiline comment. Note the details to be noted: 1. Single-line comments can be nested, and multiple lines of attention are not nested. Effect of annotations: 1. Use text to describe the program. 2. Debug the program. */classDemo2 {/*This is a program to enter the user name and password before verifying the user name and password*/ Public Static voidMain (string[] args) {System.out.println ("Please enter user name and password"); System.out.println ("Verify User name and password"); System.out.println ("AAA");//This sentence is used for testing, no tubeSystem.out.println ("Show Friends List"); }}
/*software = data + instruction + documentation (user documentation + developer documentation) The difference between a document comment and a multiline comment: The difference between a multiline comment and a document comment: The contents of a multiline comment cannot be used to generate a developer document, and the content of a document comment can produce a developer's document. Use the Javadoc development tool to generate a developer documentation. Javadoc tool use Format: javadoc-d the path to the document Java source files use the Javadoc tool to pay attention to the details: 1. If a class needs to use the Javadoc tool to generate a developer document for a software, the class must be decorated with public. 2. The contents of a document comment note are generally located above the class or method. Specifications for writing annotations: General single-line comments are located on the right side of the code, and multiline comments and document comments are generally written on top of the class or method. *//**This class is used to simulate the QQ software@author1208JAVA Basic class all students@version1.0*/ Public classDemo3 {/**the procedure is as follows: 1. First enter the user name Password 2. Verify username and password 3. Show Friends List*/ Public Static voidMain (string[] args) {System.out.println ("Please enter user name and password");//This sentence is used to enter the user name and password. System.out.println ("Verify User name and password"); System.out.println ("Show Friends List"); }}
/* Software = data + instruction + Document constants: Constants are the amount of the program's value cannot change during operation. Categories of constants: Integer constants 10 12 decimal Constant 3.14 Boolean constant Boolean constant only two values: true (correct). The False (error) character constant character constant is a single character that is enclosed in single quotation marks, which we call the character constant. String constants are string constants that are referred to as literal string constants using double quotation marks. The representation of integer constants: The representation of integers is mainly expressed in different binary (binary, octal, hexadecimal). Binary: Decimal (0~9), week (seven 0~6), hour (12 binary (0-11), 24 binary (0~23)): represents all values with a limited number symbol. The appearance of computers is to serve the human, then the real life of the human data used is basically a decimal data, then whether the computer can be stored in real life data? What kind of storage can you store it in? Binary origin. Computer records our real-life data are recorded using binary, then we need to know how to convert the decimal data into binary. Conversion between decimal and binary: decimal-to-binary method: Use decimal data to divide by 2 continuously until the quotient is 0. The remainder from bottom to top is the corresponding binary. 10 (decimal)-------->1010 (binary) binary to decimal: each bit of binary is multiplied by 2 N, N starts at 0, increments by 1 each time, and then the data of each part is added. 1110 (binary)---------> 14 (decimal) The disadvantage of binary: the binary writing is too long, inconvenient for human memory. Binary data features: composed of 0~1. Solution: A number is recorded per three bits. 1000 (decimal)------> 001,111,101,000 (binary) = 1,7,5,0 an octal data is equivalent to three bits. Conversion between decimal and octal: decimal to octal: Using decimal data to keep in the process of removingto 8, until the quotient is 0. The remainder from bottom to top is the corresponding octal system. 45 (decimal)------> 55 (octal) octal to decimal: Use each bit of octal to multiply by 8 N, n from 0, increment 1 each time, and then add the data for each part. 23 (octal)------> (decimal) octal data features: Only 0~7 these eight characters. Hex data: 0~9, A (ten), B (one), C (All), d (+), E (+), F (15), four bits is a hexadecimal data. Hexadecimal data is made up of 0~9, A-f, and several characters. Decimal is converted to 16: The decimal data is continuously divided by 16 until the quotient is 0. The remainder from the bottom up is the corresponding hexadecimal. 38 (decimal)---->26 (hexadecimal) hexadecimal to decimal: use hexadecimal to multiply each bit by 16 N, n from 0, increment 1 each time, and then add the data for each part. 34 (hex)-----> 52 (decimal)*/classdemo4{ Public Static voidMain (string[] args) {/*System.out.println (12);//integer constant System.out.println (3.14);//Decimal constant System.out.println (false);//Boolean often Volume System.out.println (' 1 '); Character constant System.out.println ("Hello World"); String constants If a data is not prefixed with any of the identifiers, the default is the decimal data. */System.out.println (10);//decimalSystem.out.println (0B10);//Binary , if a data is to represent a binary, then precede the data with a 0b start. SYSTEM.OUT.PRINTLN (010);//octal data, octal data needs to start with 0System.out.println (0x10);//hex data, hex data needs to start with 0x }}
/*In real life a lot of data is often changed. For example: Weather, mood, time, stock market ... Variable: A variable is the amount of the value that can change during a program's run. A variable is a container for storing data. What are the characteristics of the container: 1. Capacity (size). 2. Store data in a certain format. 3. Name. Declare (define) the format of a variable: capacity variable name = data. Naming conventions for variable names: first word lowercase, other words capitalized, other lowercase. Java indicates how large a variable's capacity is using a data type description. The data types in Java have two primary data types. Basic data type reference data type eight basic data types in Java: integer data type: Byte (byte) 8 bit (bit) 2^8 = 256-128~127 Short (shorter) 16bit 2^16 = 65536 int (integer) 32bit long (Long integer) 64bit 2^64 = Note: if When an integer is not added to any identity, the default is the data of type int. If you need to represent this data as a long type of data, you need to add the data followed by L to indicate that L is case-insensitive, but it is recommended to use uppercase. Doubt: the storage of integers can use four data types, then how to choose how to use it? The principle of choosing a data type: It can be small if it can meet the demand. Save memory space. Data type of decimal: float (single-precision floating point) 32bit double (double-precision floating point) 64bit Note: If a decimal is not added to any identity, then the decimal number defaults to the double type of data, if You need to represent a float type, then you need to add the F representation after the decimal. F is case-insensitive. Boolean type: Boolean type has only two values, true or FALSE. Boolean 1-byte or 4-byte if you use Boolean to declare a variable of a primitive type, then the variable takes up 4 bytes, and if you use Boolean to declare an array type, then the element of each array takes one byte. Character type: Char 2 bytes(16bit) Eight basic data types: integer: byte short int long decimal: Float Double boolean: boolean character: char string data type is: String reference data type , and is not part of the base data type.*/classDemo5 { Public Static voidMain (string[] args) {//Requirement 1: Define a variable to store the age of a normal person. byteAge = 120;//a variable of type byte is declared, which is named age and stores 120 in the age variable. //change the value of a variableAge = 121; //Requirement 2: Define a variable to store the teacher pocket money. ShortMoney = 128; //Requirement 3: Define a variable to store old Li's money. intBossmoney = 1000000000; //Requirement 4: Define a variable store Mr Zhou's boss LongAllmoney = 10000000000000000L; //Storing decimals floatf = 3.14f; DoubleD = 3.1415926537; Booleanb =false; Charc = ' a '; String Str= "Hello World"; System.out.println (str); //You need to get the data stored by a variable, just use the variable name. }}
/*How to declare a variable: How to declare a variable: The variable name of the data type; How to declare a variable two: one-time declaration of the same type variable data type variable name 1, variable 2 .... Note: 1. Variables must be declared before being used. 2. A variable with the same name cannot be declared in a scope. */classDemo6 { Public Static voidMain (string[] args) {//int age = n;//declaring a variable intAge, height;//the variable is declared//assigning values to variablesAge = 10; Height= 175; System.out.println (age); SYSTEM.OUT.PRINTLN (height); }}Type conversions
You can interpret byte as a 12 bowl, a short 22 bowl, an int 42 bowl, and a long 82 bowl. 12 bowls of full bowl of wine can be poured into 224,282 of the bowl. But 42 bowls of wine poured into 12 bowls of wine had some problems.
Thinking 1
BYTE b=126;
Q: Since the data has a default data type, 126 defaults to int type, why not error when storing to byte type.
126 is a constant Java at compile time checks whether the constant (each constant) is outside the range of type Byte. If no value can be assigned.
Think 2:byte b=128; can compile and run normally.
A compilation error occurs, and 128 exceeds the storage scope of the byte variable, so a compilation error occurs.
Thinking 2
BYTE B1=3,b2=4,b;
B=B1+B2;
b=3+4;
Which sentence failed to compile? Why?
b =3+4, 3 and 4 are constants, so Java at compile time checks whether the constant (each constant) is outside the range of byte type. If no value can be assigned. For example, b=128+1 cannot be compiled through. b=127+1; it is impossible to pass.
b =b1+b2 No, because B1 and B2 are variables, when the expression evaluates, the value of the variable is automatically promoted to int, and the expression result is an int, which is to be assigned to a byte type B, which must be coerced into type conversion.
Basic Java Learning (II.)