Program design is the management of complexity
In their minds to create a model for strengthening in-depth understanding of Java, if you encounter doubt, you will be it back to your model, and deduce the answer.
Each object has an interface
Although the object-oriented programming, we actually do to create new data types, but virtually all object-oriented design languages are used to represent data types Class Keywords. When you look at the type (Type) time when Please send it as a class (Class) to consider, and vice versa.
Object-oriented approach is not restricted to building simulation program, any program is your system, a simulation of the design concept, object-oriented technology is indeed a lot of problems can be explained as a simple solution.
Each object the provision of services
The object as a service provider is a great look at a simplified tool, not only very useful in the design process, but when others are trying to understand your code or reuse an object, it will be an object designed to be adjusted to adapt to its process becomes much simpler.
Concrete realization of hidden
public that the element followed by any person are available.
In addition to the type that creates private and internal methods of this type can not be accessed by anyone other than the elements.
The difference is protected and private access to protected members of inherited classes.
default you can access the same package in the other members.
Inheritance: multiplexed interface
Generated by the type of inheritance is to understand the equivalence of object-oriented programming method content as an important gateway.
- Is a (is-a) and as a (is-like-a) relationship between
is-a: exactly the same interface type
is-like-a: add a new interface element
Interchangeable objects with polymorphism
- Abstract base classes and interfaces
Abstract: abstract class abstract methods can only be created internally, when the class is inherited, the abstract method must be implemented otherwise the derived class is still an abstract class. To create an abstract method allows you to be a method interface without having to be placed in force may be meaningless for this method provides the method body.
Interface: provides the interface to achieve a perfect separation, multiple interfaces can be grouped together
Interface can inherit multiple interfaces.
Class does not allow multiple inheritance the main reason is that if A and B at the same time inherits C, while the b and c at the same time there is a D method, A how to determine the inheritance and that one?
But the interface does not exist such problems, the interface are all abstract methods inherited no one indifferent, so interfaces can inherit multiple interfaces.
interface b ()
interface c ()
interface a extends b, c () / / right
class b ()
class c ()
class a extends b, c () / / error
Class inheritance and interface implementation, interface also can be inherited interface. .
Object creation, use, and life-cycle
C + + object-based storage space and life-cycle when you can actually write programs.
Java dynamically created objects.
C + + must determine programmatically when to destroy the object.
Java automatic discovery of an object when no longer used.
- Collection (collection) and iterator (iterator)
List (list, used to store sequence)
arraylist: random-access element is a fixed time spent operating
linkedlist: randomly selected elements need to move in the list, its price is high, access to the more close to the table at the end of element, it takes longer.
On the other hand, if you want to insert an element in the sequence of the middle, linkedlist smaller than arraylist.
At the design stage, you can use linkedlist, in optimizing system performance, the use arraylist. Base class List and iterators arising from the abstract to you to switch between the container when the impact of the code down to a minimum.
Map (hash table, also known as an associative array, used to establish the association between objects)
Set (set of classes used to store a class object)
Queue (queue), Tree (the tree), Stack (Stack)
- Single inheritance structure
- Downcast (downcasting) and template / generic (template / generic)
- Ensure the correct clear
- Garbage collection and efficiency and flexibility of
Exception handling: Handling errors
Java and the Internet
- What is the web
- Client-side programming
- Server-side programming
Why is the success of Java
- System is easy to express, easy to understand
- Received the greatest support through the library
- Error Handling
Java and C + +