Java basics and java Basics
In object-oriented programming languages, classes are first-class citizens, and the entire system is composed of classes. Methods in Java cannot exist independently. All methods must be defined in the class. classes or objects must be used as callers for executing methods.
The Java language is a static language. After a class is defined, as long as the class file is not re-compiled, the methods of the Class and Class Object are fixed and will never change.
Method parameter transfer method: Pass the value to pass a copy of the actual parameter value into the method, and the parameter itself will not be affected. When a parameter is of the reference type, a copy of the actual object address is passed. Only two references point to the same object.
Variable-length parameters:
You can add "..." between the "type" and "parameter name" of a parameter to match an uncertain real parameter. Varargs can only be placed at the end of the parameter list, and can have at most one. When calling a method, you can also input an array in the Varargs section.
Public class Main {static int sumvarargs (int... intArrays) {int sum, I; sum = 0; for (I = 0; I <intArrays. length; I ++) {sum + = intArrays [I];} return (sum );}}
The System. out. println () method can only output strings on the console. when outputting an object, the actual output is the return value of the toString () method of the object.
ToString () method: to output the object's self-description information. The toString method implemented by the Object class is to return the class name + @ + hashCode value of the implementation class, so developers need to override this method in the subclass of the Object.