Because of the basic C #, Java basic knowledge is basically skipped, here as a review!
Three technical architectures for Java:
Java EE: (Java PlatForm Enterprise Edition) The development of business-class applications, primarily for the web
Javase, (Java PlatForm standard Edition) completes the development of the desktop program, is the other two foundation
Javame: (Java PlatForm Micro Edition) developing electronic consumer products and embedded devices such as Android
Java Data types
(1) Basic data Type (eight):
shaping : Byte byte 1 byte = 8bit The maximum amount of storage data is 255, the data range stored is between -128~127
- Short 2-byte 16bit maximum data storage is 65536, data range is -32768~32767
- int integer 4 byte 32bit maximum data storage capacity is 2 of 32 minus 1, the data range is negative 2 of 31 times to positive 2 square minus 31
- Long integer 8 bytes 64bit maximum data storage capacity is 2 of 64 minus 1, the data range is negative 2 of 63 to positive 2 square minus 63
Float type : Float float single precision 4 byte 32bit data range in 3.4e-45~1.4e38, direct assignment must be preceded by a number F or f
- Double dual precision 8 byte 64bit data range in 4.9e-324~1.8e308, you can add D or D when you assign a value or do not add
character type : single quote for char character type
Boolean Type : Boolean Boolean true/false (only true two results)
PS:. A bit is the smallest unit of data stored by a computer. That is, 1 bits, which may be 0 or 1, a byte consists of eight bits, eight bits, which can represent 256 integer values, and because byte is a symbol in Java (that is, plus and minus), so the range bit -128~127; a char consists of two bytes in Java, Used to represent a character, Unicode encoding, which is an unsigned type; int and float are composed of 4 bytes in Java; each long or double variable consumes eight bytes of storage; 1t=1024g,1g=1024m,1m=1024k, 1k=1024b
(2) Object data type (Application data type, class type)
All classes defined with the Class,interface,abstract class, String is a class in Java;
Operator
Same as C #
Structured programs
If, switch, do and while, for
Function
Object-oriented Basics (OOP)
There are roughly three types of classes in Java:
(1) Class: A basic class defined with class and does not contain abstract methods
(2) Abstract class: A class defined using the abstract class, which may or may not contain abstract methods
(3) interface: defined with interface
PS: Inheritance rule:
Classes can inherit classes, can inherit abstract classes, and can inherit interfaces;
Abstract classes can inherit classes, can inherit abstract classes, can inherit interfaces;
Interfaces can only inherit interfaces
Encapsulation (encapsulation): encapsulation makes the data and operations of the data integrated so that the person who uses the class can do it regardless of its implementation, while using its functions to achieve so-called information hiding. Encapsulation hides the internal implementation mechanism of the class so that it can change the internal structure of the class without affecting the consumer, while protecting the data.
Inheritance (inheritance): Inheritance uses the definition of an existing class as the basis for creating a new class, the definition of a new class can either add new data or new functionality, or it can use the functionality of the parent class, but not the parent class selectively. This technique makes it easy to reuse the previous code, greatly shortening the development cycle, reducing development costs, and inheriting to reuse the parent code while preparing for polymorphism.
Polymorphism (Polymorphism): Method overrides, overloads and dynamic joins to form polymorphism, including design-time polymorphism and run-time polymorphism, C + + allows multiple inheritance, but adds complexity to programming, so Java only allows single inheritance, although the inheritance relationship is guaranteed Simple and clear, but there is bound to be a large number of functional limitations; Therefore, Java introduces polymorphism to compensate for the shortcomings, in addition, abstract classes and interfaces are also important means to solve the rules of single inheritance restrictions. At the same time, polymorphism is also the essence of object-oriented programming.
Interface (interface): the definition of the interface is similar to the definition of the class, except that the keyword is different, the interface keyword is interface; The declaration format is as follows: interface interface Name {}
If a class uses an interface, it must implement all the methods of the interface, even if nothing is just an empty method body to write. And each method is public by default, so the implementation of the code must be modified with public, the number of parameters, type, and the type of the return value must be consistent with the declaration in the interface.
A detailed Java basics