Java language:
The JDK (Java Development Kit) Development Toolkit, which provides a Java development environment and a running environment--for development
JRE (Java Runtime Environment) Java Runtime Environment, containing Java Virtual machine (JVM)---Suitable for running
Java code compiles under the JDK, generates a. class file, and then runs the. class file (bytecode file) using the JVM
Java Basic Syntax:
(1) Naming specification:
1. Classes and interfaces: With a number of nouns or phrases, the first letter is capitalized. such as Jhelloworld.
2. Method name: verb or noun phrase composition, first letter lowercase, the rest of the first letter of the word capital. such as Setage ().
3. Constant name: Use all uppercase and separate the words with an underscore. such as High_name.
4. Variable name: noun or phrase, first letter lowercase, remaining uppercase, such as AuthorName.
Identifier: The first letter must be a letter, an underscore, or a dollar sign, which can consist of letters, numbers, underscores, and dollar signs, and cannot have spaces.
(2) Basic data type:
1. Boolean: Boolean (1 bytes)
2. Character type: char (2 bytes)
3. Integral type: Byte, short, int, long (1 bytes, 2 bytes, 4 bytes, 8 bytes)
4. Floating float, double (4 bytes, 8 bytes)
Data type strength Relationship: Byte < char (short) < int < Long < float < double
Weak types can be automatically converted to strongly typed, but strongly typed cannot be implicitly converted to weak types, only casts are used.
(3) Memory space:
1. Register (Registers): The fastest save area, located inside the processor, is assigned by the compiler.
2. Stack: The base data type is stored here.
3. Heap: Java object, the reference data type is stored here.
4. Static store (static Storage): Fixed storage location, also in RAM, for storing static elements.
5. Constant Storage (Constant Storage): Usually placed inside the program code, never change (typically in ROM)
6. Non-RAM storage: Not within the scope of the program
(4) Variable allocation mechanism: If the variable is the basic data type, it will open up a corresponding size space in the stack for storing the data, and if the variable is reference type data, the corresponding reference value (address) is generated in the stack memory, that is, the actual address of the object is compiled, and then the corresponding space and data of the object are generated in
Such as:
MyDate date; Date = new MyDate (8,8,2008)
First, a 32-bit object space is allocated in the stack memory (not instantiated, cannot be used), then an object is instantiated, the hash code (address) of the object is generated, and the value is assigned to date. In this way, the corresponding hash code is in the stack memory, and the corresponding space is generated in the heap memory.
(5) How to input parameters:
1. Use the string[] args parameter of the main method, which can be added at compile time.
2. Define the parameter constants within the Main method.
3. Use the Joptionalpane class bullet box input. (interface Input)
4. Use the input stream for input. (System.in.read () method or BufferedReader object).
5. Use the scanner class input.
(6) Form participation argument: the base data type is passed by value, and if it is a reference type, it is an address pass, which establishes a reference to the same space.
(7) This pointer: Resolves a hidden problem with the same name as a naming conflict between members of a method, and can call an internal constructor.
(8) Static keyword:
1. Class Method:
1) class methods can only access local variables, parameters, and static variables in the method body.
2) This and super cannot appear because there is no unique object.
3) If you want to use a non-static method, be sure to generate a local class object, then object. method to invoke.
2. Static initialization block: cannot be invoked automatically once (only once) when the class in which it resides is loaded into the JVM memory.
3. Non-static initialization block: When an object is created, it is called once before the construction method executes (depending on the object's declaration).
4. Static import: Imports only static variables and methods in the package.
(9) Final keyword:
1. When a class is final decorated, it represents the final class, which is the class that cannot be inherited.
2. When a final-modified method is used, it means that the method cannot be overridden by subclasses of the class in which it resides.
3. The parameters of the final modification method indicate that the method does not want the passed arguments to be changed within the method.
Java Fundamentals-Overview