Beginner java-Foundation

Source: Internet
Author: User

7. Behavior of the object (connected)

(3). Form participation arguments: A method signature includes a list of formal parameters (Parameter), which is used to declare the data type passed to the method. The data passed to the formal parameter is called the actual parameter (arguement). When a method is called, the actual argument must be passed to each formal parameter in the formal argument list.

(4). Call by value: In programming, the process of copying data between method calls is called by value.

How call-by-value works: Regardless of the type of argument that is passed, the associated formal parameter gets a copy of the data.

(5). Method overloading (Static polymorphism): When a class has two or more methods with the same name but has a different argument list, "only the names of the parameters are changed, such overloads are invalid."

Eg:public class employee{

Public float Computepay (double d,int x);//two parameters

Public float Computepay (double d);//A parameter

}

(6). Constructor (with participation without parameters): The constructor is a special method in the class that is used when the object is instantiated. The purpose of the constructor is to initialize the members of the object when the object is instantiated.

Constructor satisfies the property: The constructor must be the same as the class name.

The constructor cannot declare the return value, nor can it return void.

Eg:public class employee{

public int number;//member variable

Public Employee () {}//No parameter construction method

public Employee (int number) {

The use of this in the this.number=number;//constructor, which is the first executable statement in the method

The method of}//with reference structure

}

Note: By default, there is a non-parametric construction method in the class. The system default construction method is no longer generated when the parameter construction method is displayed.

8. Array (reference type)

(1). Concept: An array is a collection of elements stored in a contiguous block of memory.

Steps to create an array: declares a reference to a set of arrays.

Initializes the array with the New keyword and specifies the size of the array.

Eg:int [] score=new int[n];//Declaration array

int [] Score=new int[]{}; or int [] score={}; Declaring an array and allocating space plus initialization of elements

(2). Length of array: array name. Length The array in Java is an object, the Length property represents the size of the array, and the subscript bounds are reduced.

For advanced Use (foreach) "For array or collection traversal":

For (type variable name: Array or collection name) {}

Object array: User [] users=new user[n];

(3). Multi-heap arrays

Eg:int [] [] score;//a reference to a two-dimensional array of type int

Score=new Int[n][n];

(4). Java Documentation Tools Javadoc

Beginner java-Foundation

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.