The Java Universe review of the invincible material

Source: Internet
Author: User
Tags comment tag float double java web java se

First, the Java Foundation: 1. Introduction to Java (1) Java history (2) Key Concepts

Javase (Standard Edition) Java EE (Enterprise Edition) Javame (mini version)
JDK (Java SDK) JRE (Java Runtime Environment) IDE (Integrated development environment)
-Java SE(Java Platform,standard Edition). Java SE was formerly known as J2SE. It allows you to develop and deploy Java applications that are used in desktops, servers, embedded environments, and live environments. Java SE contains classes that support Java WEB Service development and provides the foundation for Java platform,enterprise Edition (Java EE). J2SE is the kind of desktop installer, like the Qq,word kind of application.
-java EE(Java platform,enterprise Edition). This version was formerly known as the Java EE. The Enterprise Edition helps develop and deploy portable, robust, scalable, and secure server-side Java applications. Built on the Java SE, Java EE provides Web services, component models, management, and communication APIs that can be used to implement enterprise-class service-oriented architecture (service-oriented Architecture,soa) and Web 2.0 applications. The Java EE is an Internet-based application, such as a course selection system, a corporate website, a banking system, and so on.
-Java ME(Java Platform,micro Edition). This version was formerly known as J2ME. Java ME provides a robust and flexible environment for applications running on mobile devices and embedded devices such as mobile phones, PDAs, TV set-top boxes, and printers. Java ME includes a flexible user interface, robust security model, many built-in network protocols, and rich support for Web and offline applications that can be dynamically downloaded. Applications based on the Java ME specification need to be written once, can be used for many devices, and can take advantage of the native capabilities of each device. J2ME is the development of embedded systems, such as mobile games, such as the current popular Android operating system.
-JDK(Java development Kit).
-JRE(Java Runtime Environment)
-IDE(Ind depvelopment Environment)

2. Environment Construction

JDK, Eclipse

(1) Download (2) Installation (3) configuration 3. Data type (1) Basic data Types

byte char boolean short int long float double
Simple description: Byte 8 bit because it is a signed value range ( -128~127), char and short 16 Bit,char is an unsigned range of values (0~65535); int and float are 32 bit A long and a double are 64 bits.
The difference between byte and char: 1. Char is unsigned, can represent an integer, cannot represent a negative number, and a byte is a signed type, which can represent 128-127; 2.char can be a table character, byte can not, 3.char, byte, int for English characters, can be converted to each other

Basic data Types category size range of Values Default Initial value
Byte Integral type 1 byte 8bit "-128 127" 0
Int Integral type 4 byte 32bit " -2*10^31 2*10^31-1" 0
Short Integral type 2 byte 16bit " -2*10^15 2*10^15-1" 0
Long Integral type 8 byte 64bit " -2*10^63 2*10^63-1"
Char Character type 2 byte 16bit " -2*10^31 2*10^31-1"
Float Floating point Type 4 byte 32bit "3.402823e+38 ~ 1.401298e-45"
Double Floating point Type 8 byte 64bit "1.797693e+308~ 4.9000000e-324"
(2) object/reference data type

String and custom class interfaces abstract classes
String, StringBuffer and StringBuilder The difference: 1.String is a constant, StringBuffer and StringBuilder is a variable, when modified does not generate new objects, memory use dominant; 2.StringBuffer is thread-safe, String Builder non-thread safe; 3. Execution speed: (stringbuilder,stringbuffer) >String;
1. When the amount of data is not very large, use STRING;2. Single thread with stringbuilder;3. StringBuffer for Multithreading

4. Naming specification

The

ensures that naming is unique and descriptive to ensure that resources do not conflict with each other and that memory is easy to understand.  
The composition of the ① identifier: Letters, numbers, underscores, $, cannot start with a number, cannot use keywords and reserved keywords. PS: keyword is defined in Java has a specific function of the identifier, can not be used as a normal identifier  

② The name of the package  
Java package names are made up of lowercase words. Each Java programmer can write its own Java package, in order to guarantee the uniqueness of each Java package naming, the latest Java programming specification requires programmers to add a unique prefix to the name of the package they define. Because domain names on the Internet are not duplicated, programmers generally use their own domain name on the Internet as the only prefix for their packages.  
For example: Net.frontfree.javagroup.  
The name of the ③ class  
class names must start with uppercase letters, and the other letters in a word are lowercase. If the class name consists of multiple words, it is recommended to capitalize the first letter of each word, such as testpage. If the class name contains a word abbreviation, it is recommended that each letter of the word be capitalized, for example: Xmlexample. Because classes are designed to represent objects, it is recommended that you select nouns when naming classes.   The
④ method is named  
The 1th Word of the name of the method should start with a lowercase letter, and the following words are suggested to start with a capital letter (Hump principle).  
For example: Sendmessge ().   The
⑤ constant is named  
the name of the constant should all be in uppercase letters and indicates the full meaning of the constant. If a constant name consists of multiple words, it is recommended to use underscores to split the words.  
For example: Max_value.  
⑥ parameter naming (Hump principle)  
parameter naming conventions and methods are the same, and in order to avoid confusion when reading a program, try to ensure that the name of the parameter is as clear as possible in the case of a word. * * Note: The properties of **1, class are allowed to not initialize, 2, the variables inside the method are initialized  
⑦javadoc comment  
Javadoc Comment is a multiline comment that starts with/ * and /ends. Comments can include some HTML tags and special keywords. The advantage of using Javadoc annotations is that comments written can be automatically converted to online documents, eliminating the hassle of writing program documents separately.

At the very beginning of each program, the general description of the program and the copyright information are generally used with Javadoc annotations. In the main program, you can add Javadoc comments for each class, interface, method, variable, and the first part of each comment summarizes the functions of the class, interface, method, and variable, which should occupy a single line to highlight its generalization, after which a more detailed description of the paragraph can be followed.
After a descriptive paragraph, you can also follow some special paragraphs that begin with the Javadoc comment tag, such as the @auther and @version in the example above, which appear in the generated document in a specific way.
Although adding a comment does not make a poorly designed program a good program, writing a program according to a programming specification and adding good annotations to your program can help you write out programs that are beautifully designed, run efficiently, and easily understood, especially when multiple people work together to complete the same project. As the saying goes, "Ax", it's good to spend a little time adapting to the Java programming specification.

5. Process Control

Branch Statement (conditional statement)
Loop statement ()

6. Classes and Objects (1) Analysis of member variables, local variables and global variables

Member variable: A variable defined in the variables section of a class body, also known as a property.
Local variables: Refers to variables in a program, defined in a particular method or block of statements, relative to global variables.

the difference between an instance variable and a class variable
1. Instance variable: Without static decoration, it can only be called through the object and the same instance variable of all objects is shared with different memory space;
2. Class variables: Also known as static variables, with static decoration, it can be called directly with the class name can also be called by the object, and all objects of the same class variable is shared the same block of memory space;

(4) How to construct Java
 1.程序运行的时候构造方法就被加载;2.每个类都有构造方法,如果程序员给类提供构造方法,编译器会自动创建一个默认的构造方法; 3.构造方法重载类似于方法的重载,一个类可以有多个构造方法,但参数列表必不同。
(5) static (static variable, static method and static initialization block)

Meaning: the "static" keyword indicates that a member variable or a member method can be accessed without an instance variable of the class to which it belongs. The static method in Java cannot be overridden because method overrides are dynamically bound based on the runtime, while the static method is statically bound at compile time. The static method is not relevant to any instances of the class, so it is conceptually not applicable.
is static modifier, what is static modifier? As you know, any variable or code in the program is automatically allocated by the system at compile time to store the memory, and so-called static refers to the memory allocated after compilation will persist until the program exits the memory will release the space, that is, as long as the program is running, then this memory will always exist. What is the point of doing this?
In a Java program, everything is an object, and an object's abstraction is a class, and for a class, if you want to use his members, you would normally have to instantiate the object before you can access those members by reference to the object, but there is an exception. Is that the member is declared with static (the access control of the class is excluded here)
Static variables and Static methods:
1. Static variables can be directly called by classes and objects; 2. Static methods cannot directly invoke non-static variables and non-static methods, can be called by creating objects, 3. Static and non-static variables in the class can be called directly by the normal method;

(8) passing by value and by reference

Parameters are passed by value, passing a copy of the value, meaning that it is not correlated after passing, and does not affect the original value.
Arguments are passed by reference, passing a reference to a value, meaning that both before and after the pass point to the same reference (that is, the same memory space), so the external changes to the referenced object are reflected on all objects.
Pass-by-value and reference delivery

(9) object class (is a superclass of all Java classes)

Object ()
Default constructor method
Clone ()
Creates and returns a copy of this object.
Equals (Object obj)
Indicates whether a different object is "equal" to this object.
Finalize ()
This method is called by the object's garbage collector when the garbage collector determines that there are no more references to the object.
GetClass ()
Returns the run-time class of an object.
Hashcode ()
Returns the hash code value of the object.
Notify ()
Wakes up a single thread waiting on this object monitor.
Notifyall ()
Wakes all the threads waiting on this object monitor.
ToString ()
Returns the string representation of the object.
Wait ()
Causes the current thread to wait until other threads call the Notify () method of this object or the Notifyall () method.
Wait (long timeout)
Causes the current thread to wait until another thread calls this object's notify () method or the Notifyall () method, or exceeds the specified amount of time.
Wait (long timeout, int nanos)
Causes the current thread to wait until another thread calls this object's notify () method or the Notifyall () method, or some other thread interrupts the current thread, or has exceeded an actual amount of time.

(Ten) UML

Second, Java advanced 1. Java Object-oriented programming (OOP)

Object-Oriented Programming benefits: Code development modularity, ease of maintenance and understanding, code reusability, enhanced maintainability and flexibility of code,  
Encapsulation : Encapsulates objects into classes, classes hide implementation details inside, Provides properties and methods uniformly for easy code maintenance.  
Access modifier in Java: 1.private: Only within this class can be accessed and cannot be accessed (inherited); 2. Default (no access modifier), only use 3.protected in this class and in the same package: can be in this class, the same package , and the subclass of the class is accessed (the subclass may not be the same as the parent class under a package); 4.public: Public, can be accessed (inherited) inner class:??????  
Inherits : Inheritance is a relationship between a class and a class that can use the properties and methods of the parent class (the properties and methods of the parent class cannot be privata), increase the reusability of the Code, and provide a precondition for the implementation of the polymorphic.  
Note: Only single inheritance can be achieved in 1.java, 2.super () represents the constructor method that calls the parent class in the subclass, 3.this. Property/this. Method, which represents access to the properties and methods in this class, this () represents the constructor method that calls this class; 3. The relationship between a class and a class: an inheritance relationship; a dependency (which is the most common relationship between a class and an interface) implementation relationship (implementation is the most frequent relation between classes and interfaces) The relationship between a class and a class 4.final keyword: You can decorate classes, methods, properties, and variables,  
Decorated class The class cannot be inherited, the method cannot be overridden, the property cannot be automatically initialized, the modifier variable can only be assigned one time value   the execution order inherited in
5.java: Parent Class Property Initialization –> Parent class constructor method –> Subclass Property Initialization – > Subclass Construction Method

Polymorphism Summary: The rewrite overriding and overloaded overloading of the method are different manifestations of Java polymorphism. Overriding overriding is a representation of polymorphism between a parent class and a subclass, and overloading overloading is a representation of polymorphism in a class. If you define a method in a subclass that has the same name and arguments as its parent class, we say that the method is overridden (overriding). When an object of a subclass uses this method, the definition in the subclass is called, and for it the definition in the parent class is "masked". If more than one method with the same name is defined in a class, they either have a different number of arguments or have different parameter types, which is called a method overload (overloading). The overloaded method is to change the type of the return value.

2. Abstract classes and Interfaces

Abstract classes (abstract classes are the methods that constrained subclasses must have, and do not care about the implementation of subclasses):

Abstract class Summary: 1. A class that contains abstract methods must have an abstract class, which defines abstract class A, which does not necessarily have an abstract method, and an abstract class can also define a common method;
2. Abstract classes must be decorated with public or protected;
3. Abstract classes cannot be used to create objects;
4. If a class inherits an abstract class, the subclass must implement all the abstract method methods of the parent class.

An interface (an interface refers to a method or function that is called by another person):

Interface Summary: 1. The methods in the interface are abstract methods; 2. A class can implement multiple interfaces, and a non-abstract class that implements an interface must implement all the methods in the interface (in exchange for
In other words: for an abstract class that follows an interface, you can not implement an abstract method in that interface.

The difference between an abstract class and an interface:
The following example realizes an alarm door, the door switch is the door of this kind of things unique properties, but the alarm is not (all doors are not necessarily the door will alarm), the alarm can only be said to be a kind of behavior, a door may or may not have behavior, so with the interface to define this behavior, Your door has the alarm function to implement (implements) this interface chant, which is not to achieve.

Summary of differences: 1. Abstract classes can have non-abstract methods, and interfaces within the methods are abstract (public abstract); 2. Abstract classes are used to abstract the common attributes of a class of things, then
3. The properties defined in the interface are final and the interface definition method can only be public; 4, a class can implement multiple interfaces but only
can inherit an abstract class;
Abstract classes and interfaces in a detailed

3. Packages and modifiers 4. Common class (1) String class (2) Packing type

Wrapper class for the base data type: Byte char boolean short int long float double
Byte Character Boolean Short Integer Long Float Double
Objective: To convert basic data types into object types, Java is an object-oriented language, object types can carry more information and operations, and wrapper classes implement class compareable interfaces to achieve comparisons between objects.

Equals () compares the values (contents) of two objects.
"= =" compares the two-object reference (memory address) with the same, and is used to compare the values of variables of two base data types for equality.

(3) Date class (4) Math class 5. Set Frame

Java Collection Classes
Basic interfaces in the Java Collection class:
Collection: is the upper interface of the collection class, and the main interface of inheriting with it is set and list.
List: Holds elements in a particular order and can have repeating elements;
Set: Cannot have duplicate elements, internal sort (unordered);
MAP: Key-value pair Key–value,value can be multi-valued
Collection class attributes (the difference between several common classes)

The Java Universe review of the invincible material

Related Article

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.