www, arrays equals, abstract classes and interfaces, boxing and unboxing, final assignment

table of Contents

2019.12.31 brush title notes

www

www is the abbreviation for World Wide Web


equals array

An object is an array, having an array of different types of different classes. Array is a reference data type. It inherits the Object class, but there's equals () method is not rewritten before. Thus two arrays of objects using equals () is referenced in the comparison array.

Using that Arrays.equals () comparing the content of two arrays


The difference between abstract classes and interfaces

Abstract class : abstract class with abstract modification, abstract methods abstract class subclass must implement, or subclass must use abstract modification. The default permissions modifier for the public, if the child is defined as private class can not be inherited. No abstract class instance object.

Interface : The interface with the implicit variable public static final modification, and needs to be given an initial value. The method of implicitly using public abstract modification, where public is necessary. JDK1.8 before a predetermined method in the interface can have a specific implementation, there may then be a specific implementation.

The difference between abstract classes and interfaces:

  1. Abstract classes can inherit only once, but can implement multiple interfaces.
  2. Interface modified public static final variables, and need to be given an initial value. Therefore, the implementation class can not be redefined not change.
  3. Default interface methods public abstract, is not static, the method does not allow interface subclass coverage. The abstract class allows static method.

Unpacking Packing Methods

a = Integer.parseInt("1024");
b = Integer.valueOf("1024").intValue();

a and b are integer type variables and their values are equal.

intValue () int is an Integer object into basic data types;

the parseInt () is a String into int basic data types;

valueOf () is turned into a String Integer object type.


Assignment of the final member variables modified in three ways

  • When the assignment statement
final a = 10;
  • Assignment in the constructor

  • In the initial assignment code block

final a;
{
    a = 10;
}

To sum up, the assignment is to complete the process before the object is created.

Guess you like

Origin www.cnblogs.com/peekapoo/p/12144306.html