the basic framework of Java
Read source code (JDK)--Learn a lot, elegant programming skills based on why: Design (why others want to use such a design to achieve such a function)-based on how> > (designers, architects)
Description: Reading code is much more difficult than learning code!
Idea Create new Project-create class file
The class name of the file name and public decoration must be the same
A Java file that has and can have only one class that is modified by public
There can be multiple Java classes, except that these Java classes cannot be modified by public
Javac the compilation and execution unit, is the class is not a file
Key Words
Overview: Words (names) that are given a specific meaning by the Java language
Features: The letters that make up the keywords are all lowercase
Keyword considerations: Goto and Const exist as reserved characters and are not currently used
There are only 49 keywords listed in PPT in total in Java
keyword considerations:
Goto and const exist as reserved words, not currently applicable
High-level Notepad like editplus,notepad++, highlighting for keywords
Java Syntax Rules If a Java file has a class that is public-decorated
The name of the Java file must be exactly the same as the public class that is publicly decorated
There must be only one class in a Java file that is modified by public
But there can be multiple Java classes, which cannot be modified by public
Javac the compilation and execution units are classes rather than files
identifier (name of your own)
Meaning: A sequence of characters used to name a class, interface, method, variable, etc.
Composition rule:
Precautions
in the actual development
The names of classes and interfaces, variables and methods, packages, constants, in order to make our code more readable: There are conventions for naming rules
1. Classes and Interfaces:
One word: The first letter of the word is capitalized, and the remaining characters are lowercase.
Multiple words: The first letter of each word is capitalized, the remaining characters are lowercase. To make the code more readable. public class Javasign/public Class Helloworld/getelementbyid
2. Names of variables and methods:
One word: all lowercase (main,get,set,a)
Multiple words: First letter lowercase, remaining words capitalized (Tostring,getclass)
3. Package:
Role: To organize Java classes, avoid naming conflicts
One word: all lowercase. (Javabasic)
Multiple words: Domain reversal form: com.cskaoyan.www
IP address-domain name is unique in the network
Domain name: Not really only one domain name
4. Constants:
One word: All letters capitalized, for example: Pi,max,min
Multiple words: All letters are capitalized, but the words are concatenated with each other, for example: Max_value,min_value,student_age
Notes
Overview: Text used to interpret the description program
2. Classification
Single-line Comment://Comment text
Multiline Comment:/* Comment Text */
Document comments:/** Note Text * * When creating JDK documents, let the compiler ignore the text that the comment symbol refers to, and the text is only for our developers to read
3. Application
Write the comments first, then write the code
The first step, complete the XXX function//easy to debug
4. Benefits of annotations
1. Grooming Ideas
2. troubleshooting, reading the code, judging the procedure in the code, and whether it is consistent with the description of the annotation (logic)
This is a single-line comment
?
/*
Multi-line comments
*/
?
This is a document comment
*/
ConstantsOverview
The amount of changes that will not occur during program execution
Constant Classification
- Literal Constants
String constants: "Hello World"
Numeric constants: 34 59
Decimal constants: All decimals: 0.2.0.1
Character constants: Constant ' A ', ' B ', enclosed in single quotes '
When characters and strings are stored, the values that represent the character or sequence of characters are stored; Each character has a corresponding value.
Single character with ", >=2 characters with" ".
ASCII Code table
' 0 ' 1 '
code table |
ASCII |
character |
value |
' A ' ' B ' C ' |
All-in-all |
$ |
' a ' B ' C ' |
98 |
- Custom Constants (object-oriented)
binary number Binary
Value range (0 and 1), base 2
Turn decimal 110 = 1 * 2^2 + 1 * 2^1 + 1*2^0 =7
Each digit represents the actual value =x*2^n-1
octal
Value range (0-7), base 8
Turn decimal 567 = 5 * 8^2 + 6 * 8^1 + 7*8^0 =
Each digit represents the actual value =x*8^n-1
decimal
1. Made up of 0~9. Integers are decimal by default
hexadecimal
Range of values (0-9 abcdef), Radix 16
Turn decimal c3= 12 * 16^1 + 2 * 16^0
Each digit represents the actual value =x*16^n-1
conversions between different binaries
Constants (different representations of the binary)
//1100 decimal:
System. out. println ( "1100");
//1100 binary:
system. Out. println ( "0b1100");
//1100 octal:
system. Out. println ( "01100")
// 1100 of 16 binary:
system. Out. println ( "0x1100")
Constants (Symbolic data notation)
Within the computer, there are 3 notation numbers: The original code, the inverse code, and the complement .
All data is performed in the complement.
Symbol bits do not need to be calculated separately and can be directly and numerically involved in the operation
Positive and negative numbers
One binary to indicate positive or negative, 0 positive, 1 negative
Original code: Numeric value with sign bit 1100: positive 0000 1100 = +1100
? Negative 1000 1100 indicates-1100
Anti-code: Positive inverse code is the same as the original code, negative number of the inverse code to its original code is bit-wise (1 is 0,0 1), but the sign bit except.
Complement: The complement of positive is the same as the original code, the complement of negative is in its inverse code of the bottom +1.
The original code and its corresponding complement of the relationship: the original code and complement is some kind of complementary relationship.
The original code is known to complement, and the complement is known to seek the original code. ////////////////
0000 0000 is 0
1000 0000 Yes-0 anti-code: 1111 1111 complement: 0000 0000 (Anti-code + 1, carry, reserved eight-bit)
variables
Variable definition Format (fixed format):
Data type variable name = initial value (literal constant)
int getValue = 10;
Data Type
The Java language is a strongly typed language that defines specific data types for each type of data, and allocates memory space of different sizes in memory. (Very strict on the data type)
category1. Basic Data Types
Each type occupies a different space, and the range of data represented is not the same.
Numeric type
Integer type (byte (-128-127) (one byte), short (2), int (4), Long (8))
Floating-point type (flout,double)
Character type (char)
Boolean Type (Boolean)
Integer default: int (e.g. 10) decimal default: double (e.g. 0.0)
Such as:? Flout C = 0.1 pair: Flout C = 0.1f
2. Reference data Types
Classes (Class)
Interface (interface)
Array ([])
Type Conversions
Boolean types cannot be converted to other data types
Default conversions (small type conversions to large types) (large range types cannot be placed in small ranges)
-
Byte,short,char->int->long->float->double
Byte,short,char do not convert to each other, they participate in the operation first converted to the int type.
Coercion type conversions (large type to small type)
-
-
Short B = 100;
BYTE AA = (byte) (b+1);
0 1000 0010
//
Byte bb = (byte) 130//out of range, intercept limited number of bits
Day02-java Basic