abstract class: classes that are decorated with an abstract class cannot be instantiated, that is, cannot be new to an object. Abstract method: Method of the abstract modification. Only the declaration, no implementation (no {}, if there is {} but the inside is empty, this is also implemented, called the empty implementation). Abstract classes do not have to be all abstract methods, can also write implementation methods.
interface (interface): a special abstract class in which all methods are abstract. The specification of a class is defined, and the class implementing the interface adheres to the rules set by the interface. The variables defined in the interface must be initialized, the default type is public static final (that is, constant), the methods in the interface are abstract methods, and the default type is public abstract. An interface can inherit another interface, but an interface cannot implement another interface. A class can implement multiple interfaces, but can inherit only one class. (Multi-implementation, single-inheritance) interfaces differ from abstract classes: interfaces are special abstract classes, and methods in abstract classes are not necessarily abstract methods, but the methods in the interfaces must be abstract. Interfaces cannot be instantiated.
the similarities and differences between abstract classes and interfaces: Both are abstract constraints, or specifications. are not instantiated. You can put abstract methods inside. However, the interface requirements must be all abstract methods. The essence of an abstract class is a class, which can only be inherited by a single sheet, whereas an interface may be implemented more than one (a class can implement multiple interfaces)
polymorphic: There are multiple states of an object. Crows are both bird type and animal type, and can be biological type. Student stu = new Student (); Stu it can be a student type, of course, it is also a people type.
Upward Transformation: Student Of course is also people type, (crow must be bird, animal, creature) people stu = new Student ();
Downward Transformation : (to force type conversion) People stu = new Student (); Student stu1 = (Student) Stu;
Final: final state. Represents a fixed pattern and cannot be modified to extend
When it modifies a class, it means that the class cannot be extended by inheritance; When the method is decorated, it means that the method cannot overwrite (override) The method in the class, and when the variable is modified, it represents a constant.
Static : statically. Static can modify variables, methods, blocks of code, and so on. Normally, every new object is allocated a small space in memory to store it, but the static modified member variable belongs to the entire class, which is stored in a shared area in memory, and all objects use a single static member variable together. () static member variables and static methods can be directly used with the class name. Member variable name Class name. method
String class: A string is a constant whose object cannot be changed once it is created. The methods that appear to modify string values are actually creating a completely new string. String through + can splice other things, and silently to the people's data type into a string type, the concatenation of the string is a new string object. The opposite is stringbuffer, which can be spliced by append (). The main difference between StringBuffer and string is that the value of an object created by StringBuffer can be changed, and the value of a string object cannot be changed once it is created.
Two ways to create an object:
String str1 = new String ("AAA");
String str2 = new String ("AAA");
This is two objects, and as soon as new, an object is created.
String str1 = "AAA";
String str2 = "AAA";
The same object. For specific explanations see: http://www.cnblogs.com/mengdd/archive/2013/01/03/2842846.html
array: A collection of the same data types. Several ways to define an array: int[] array = new INT[10]; int array[] = new INT[10]; Int[] A = {1,2,3,4}; Int[] A = new int[]{1,2,3,4};
Collection (collection): multiple elements are formed into a single unit. The collection cannot hold the basic type of data, and the object that is the wrapper class to save it, that is, the collection can only hold objects. Previously, the compiler's data type was object, and when inserting an object, no matter what type of object It was, the return type of all objects was object when get, obviously, this is problematic. To avoid such errors, we can use angle brackets to specify the specific data types that the collection stores. List<string>
Previously, after putting an object into a collection, its type was type object.
The list collection is an ordered collection, and the elements in the collection can be repeated, and accessing the elements in the collection can be accessed based on the index of the element.
The set collection is an unordered collection, and the elements in the collection cannot be duplicated, and access to the elements in the collection can only be accessed based on the element itself (and the reason that the elements in the collection are not allowed to be duplicated).
The map collection holds elements of the key-value pair form, which can only be accessed by the key of each element when accessing its value.
The data that the TreeSet requires to be put in is comparable.
comparison of ArrayList and LinkedList:
The underlying data structure of ArrayList is an array, which performs a search operation efficiently.
The underlying data structure of the LinkedList is a doubly linked list, which is highly efficient to insert and delete.
If ArrayList inserts or deletes a piece of data, the data after that data insertion point or delete point is moved and inefficient.
The bottom of the hashset is implemented with HashMap. HashMap is the object that the key stores HashSet add, and value is a unified object (unrelated to us).
The underlying data structure of HASHMAP is an array.
the difference between array and ArrayList : Collections (ArrayList) can only hold objects, and arrays can hold objects as well as the basic types of data.
Two ways to iterate through a collection:
Iterator: Iterator. First the collection gets an iterator, and then the iterator is usually used Hasnext (), Next ()
Foreach:
generics: The so-called generics, is the parameterization of the variable type. There are programmers who specify the data types that a collection can hold, previously, the data type of the compiler is object, and when an object is inserted, no matter what type of object it is, the return type of all objects is object when get, obviously, this is problematic. To avoid such errors, we can use angle brackets to specify the specific data types that the collection stores. List<string>
wrapper class:8 Basic data types, not objects. There are 8 corresponding wrapper classes defined for this Java, and they can be used as objects. Automatic boxing and unpacking: After JDK1.5, automatic Boxing: The basic data type is automatically converted to the wrapper type; automatic unpacking: The wrapper type is automatically converted to the base data type.
The reflection mechanism of Java:
Dynamic (run-time) Gets the information of the class and the ability to invoke the object's methods dynamically.
To use reflection, you first need to get the class object corresponding to the classes you want to manipulate.
In Java, regardless of how many objects of a class are generated, these objects correspond to the same class object.
This class object is generated by the JVM, which is able to learn the structure of the entire class.
There are three common ways to get a class object:
1. Use the static method of class: Class.forName ("....") ");
2. Use the object's GetClass () method: Object. GetClass ();
3. Class syntax for using classes: String.class;
Class : Each class starts with a class loader that generates a class object that stores the information for that class.
Java io stream: byte stream: Inputstream,outputstream two abstract classes and the following sub-character stream: Reader,writer two abstract classes and the following subclasses at the bottom, the flow is actually byte form.
Java Basics Summary