02-java Foundation and object-oriented (supplementary)

Source: Internet
Author: User

Reference data type
    • Data types in Java can be divided into basic data types and reference data types in two major categories

    • int, float, char, Boolean, etc. are all basic data types

    • Class types are reference data types

    • Reference data types are similar to pointers in the C language, and multiple reference data types can reference the same object

    • A variable of the base data type has a copy of its own value, and the reference data type is the value that points to its own heap space.

Polymorphic
    • Polymorphism in Java can only occur in methods, and the exact same properties between child parent classes do not occur polymorphic.

    • The exact same attributes between child parent classes determine which one to access by referring to the type rather than the actual object's type.

public static void Main (string[] args) Analysis:

    1. Public declares that main is common so that the JVM can access the main method, which is equivalent to a cross-package invocation, so it is the same reason that the class name that contains the main method is also decorated with the Because the JVM needs to find it and the main method in it.

    2. Static indicates that the main method does not need to be accessible by a new object.

    3. void Main (string[] args) is a method return value, method name, and method parameter.

In the Java language, you can add a * * @Override * * Prompt to a method overridden by a subclass so that the compiler checks whether the method overrides are legitimate.

    • This is good, avoid rewriting the function name and so on wrong, but the compiler will not error the embarrassing situation.

    • A subclass can implement multiple interfaces, but all of the methods in the interface must be implemented, or the subclasses will become abstract classes.

02-java Foundation and object-oriented (supplementary)

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.