Java-Object Oriented

Source: Internet
Author: User
Tags variable scope

  Identifier keyword Java basic data type (four classes eight, type (size): Byte character type: Byte (1), char (2), Integer: Short (2), int (4), Long (8), float: float (4), double (8), Logical Type: Boolean (1)) operator expression and statement branching Loop method Variable Scope recursive call    How do I use a command prompt to hit a jar package? 1. Open a command prompt, switch to the first level you want to hit into the jar package directory 2, input JAR-CVF xxx.jar * *, enter the//format explanation: JAR-CVF + want to hit the jar package name + want to hit the content (* * For all the contents of the current directory)     How can I introduce a jar package?   directly set the path of this jar file into classpath.     Package:  * has a conventional naming method that writes your company's domain name upside down, such as: com.bjsxt.java140. * Classes without a package are called naked classes * The compiled class file must be in the correct directory (consistent with the specified package), otherwise the other classes not in the same directory will not be accessible. * After JDK1.4, this type of source code may have an impact, delete or transfer to another directory under, do not let the source code is located under ClassPath. * The parent directory of the topmost package of the class file must be located under ClassPath. * Executing a class requires writing the full-package name. * JDK inside, when used, only a java.lang does not need to be introduced, the other, you want to use it inside the class, must be introduced. The    variable:  is divided into the underlying data type variable and the reference data type variable underlying data type variable: A block of memory in memory, once defined and assigned, the name and value are stored in this memory reference data type variables: Two memory in memory, once defined and assigned value, One piece of memory holds the real value (that is, the specific instance of new), and the other memory holds the name it defines and the memory address where its true value resides (that is, the object's reference). A small chunk of memory points to a chunk of memory       Scope of variables (member variables and local variables):  * Note: Static local variables are not defined in Java, and there are no statically local variables. * Important differences between member variables and local variables: member variables of the underlying data type if you don't give it a startInitialization, Java automatically initializes it, and the local variable of the underlying data type must be initialized to be used, whereas a variable of the reference data type (whether a member variable or a local variable) needs to be instantiated, otherwise null, and you can use it without instantiating it. Only the system throws a null pointer exception (NULLPOINTEXCEPTION) when it is used. * Static member variables are part of the entire class and are shared by all objects that are new to the class; You do not need to have new objects to be accessible directly from the class name, rather than static member variables that need to be new out of the object for access. * The life cycle of a static member variable depends on the class, and the life cycle of a non-static member variable depends on the object that the class is new, and the life cycle of the local variable depends on the curly brace where it is defined.     Constants (variables with final modification):  * constants also belong to the category of variables, it is a special variable, is a variable can not change the value, it is called a constant.      Memory Partition: 1, code segment codes area code 2, data segment, static variables and string constants 3, stack stack local variables 4, heap loaded new things      Object-oriented design idea: When you think about a problem, you should not consider the first step. What do I have to do, and what do I have to think about in the second step? 1, first of all to consider, as this problem, in this problem domain should have what kind of object, this is the 1th; 2, and then consider these classes each of these objects each kind of object should have what properties and methods, this is 2nd; 3, and then consider what kind of relationship between class and class. Concepts of     classes and objects: Classes are abstract objects of a class of things with common characteristics: it is a specific instance of this kind of thing 1, the object uses the computer language to describe the thing in the problem domain, the object Passes "attribute (attribute)" and " method) "to correspond to the static and dynamic properties of the object, respectively. 2. A class is an abstract concept used to describe an object of the same type, which defines the static and dynamic properties that this class of objects should have. 3, the class can be regarded as a kind of object template, the object can be regarded as a concrete instance of the class. Relationships between     classes (objects): * Association * inheritance * Aggregation   * * Aggregation   * * COMBO * polymorphism * Implementation    inheritance relationship (general and special):   As long as can say: "XX is a kind of xx". Such as: Football player is a ball player, basketball player is a ball player, volleyball player is a ball player, ball player is an athlete, swimmer is an athlete, shooter is an athlete    aggregate relationship (whole and part):  As long as can say: "XX is part of XX." Such as: The Captain is a part of the team, the team members are part of the group, the arm is a part of the person, the brain is a part of the human body is a part of human. The fine point of aggregation can also be divided into: aggregation, aggregation: Pine aggregation Captain, a captain can be a basketball team captain can also be the team captain combination: Tight polymer head, never heard a head belongs to you also belong to him     implementation relationship (parent class and subclass):       polymorphism (also called dynamic binding, also called late binding):  * refers to determining the actual type of the referenced object during execution, not during compilation, and calling its corresponding method according to its actual type. * There are three necessary conditions for polymorphic existence:  * * 1, to have inheritance   * * 2, to have overrides   * * 3, the parent reference data type variable to point to the subclass object   Note: Once the three conditions are met, when you tune the method of the base class is overridden, the actual new is the child class object, the method in the subclass object is called.     access control: The  java permission modifier public protected private is placed before the member definition of a class to qualify other objects for access to members of that class of objects. Private: Class internal default: Class inside, same package protected: Inside class, same package, subclass public: Inside class, same package, subclass, anywhere * Permission decorations for class can only be used with public and default,public Classes can be accessed anywhere, and the default class can only be accessed by classes within the same package. Overloading and overriding of      methods: Overloading is the same class, the same method name, different parameter list (number or type), regardless of the return value type. Overrides are subclasses that redefine the existing methods of the parent class and must have the same return value type, method name, and parameter list as the parent class method. * The overridden method cannot use more restrictive access than the overridden method, that is, if the access to the method of the parent class you override is protected, then the access rights of the method that you subclass override cannot be private or defAult, can only be protected or public. Construction method in      Inheritance: The construction method of its base class must be called during the construction of the  * subclass. * Subclasses can use Super (argument_list) to call the constructor of a base class in their own constructor method.   * * Use this (argument_list) to invoke the other construction method of this class   * * If you call super, you must write in the first line of the subclass construction method, it is necessary to construct a father before the son, so put the first line. * If the constructor of the subclass is not displayed in the construction method of the child class (and the super is not written), Java defaults to calling the base class's parameterless construction method. * If the construction method of the base class is not displayed in the subclass construction method, and there is no parameterless construction method in the base class, the compilation error occurs. The Equals method of the    object class: the implementation code for the Equals method of the  object class is as follows: Boolean equals (Object o) {    return this ==o;} * The object class is defined as the public boolean equals (Object obj) method, which provides the logic to define whether an object is "equal". * The Equals method of object is defined as: X.equals (y) returns True when X and Y are references to the same object, otherwise false. * Some classes provided by J2SDK, such as String, Date, and so on, override the Equals method of the object class, call the Equals method of these classes, X.equals (y), when X and Y refer to Objects of the same class, and the contents of the properties are equal (not necessarily the same return true, or False if it is returned. * You can override the Equals method in a user-defined type as needed, and you should also rewrite the Hashcode method.     Object Transformation (casting):  * A reference-type variable of a parent class can "point to" the object of its subclass. * A reference type variable of a parent class does not have access to the newly added attributes (including static and dynamic properties) of its child class object. * You can use the reference type variable instanceof class name to determine whether the object that the reference type variable "points to" belongs to the class or subclass of the class.   * * InstanceOf: is one of the instances of a class or its subclasses. * Subclasses of objects can be used as objects of the parent class, called upward Transformation (upcasting), and vice versa called Downward transformation (downcasting). Extensibility (Extensibility): * A typical rule is to add new things at the same time as far as possible not to modify the original already done things, this is called scalability is good.     Abstract:  * classes called abstract classes, which are modified by abstract, are called abstract methods using abstract methods. * Abstract classes cannot be instantiated. * Abstract methods only need to be declared, but not implemented. * Classes containing abstract methods must be declared as abstract classes, and abstract classes must be inherited (it is said that if you define an abstract class that is not inherited by other classes, it is meaningless because abstract classes cannot be instantiated, so you cannot use static and dynamic properties in the abstract class). Subclasses of inheriting abstract classes must override all abstract methods in the abstract parent class * Supplemental NOTES: Abstract class can have non-abstract methods, and interface cannot.    final keyword: The value of the  * final variable cannot be changed and must be initialized.   * * Final member variable   * Final local variable (formal parameter) * Final method cannot be overridden * Final class cannot be inherited    interface (interface):  * interface is abstract method and constant A collection of definitions for the value. * In essence, an interface is a special kind of abstract class that contains only constants, method definitions, and no variables, and no method implementations. * Multiple unrelated classes can implement the same interface. * A class can implement multiple unrelated interfaces. * Similar to inheritance, there is polymorphism between the interface and the implementation class. * Supplementary Note: interface can only extends interface, can not extends class or extends abstract class, interface itself can not implements any interface& nbsp;   Summary: * Memory analysis throughout * object and class Concepts * Class (object) Relationships * Object-oriented design ideas * class* new  * * Reference Concept   * * Constructor Method Concept * Method overloading (overload)   * * Construction method overload * this* static* PAckage & import* Private default protected public (default is not a keyword) * extends* overwrite* final* object  * TOSTRING&N Bsp * * equals* upcasting downcasting* polymophysm/(dynamic/late) binding* abstract class* interface  * * Implements

Java-Object Oriented

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.