Summary of the third week

Source: Internet
Author: User


The method name can be any valid identifier, named rules and variables.
The customary method is a verb.
The return type is the type of data that the method returns to the method call.
The formal parameter list is a comma-separated list of parameter declarations that are passed to the method.
The method name, return type, and parameter list define the method signature, which is the signature that uniquely identifies the method.

Access modifiers
Public indicates that the defined method is common and can be called in any program.
Static indicates that the defined method is static.

Three elements of recursion:
A code to end the recursion
A call to continue the recursive
A test that stops or resumes recursion.
View API
1. Explore the Classpath
2. View class Information
3, explore the method: return type, method name, formal parameter list.

In structured programming, the program is designed around the tasks to be solved.
In object-oriented programming, programs are designed around objects in the problem domain.

Object-oriented Solutions
Object: An object can be any person, kind, or entity that appears in the problem domain, simply saying "something".
After the objects in the problem domain have been found, we will write a class that describes the properties and behavior of each object.

Make up two parts of a class: property, Behavior.

An object is a concrete entity that exists, with clearly defined characteristics and behaviors.

Object-oriented: a way of knowing things, paying attention to the whole cognition of things, the most accord with the natural thinking habit of mankind.

A class is an abstraction of an object that is an instance of a class.

A class is a collection of sets of objects that have the same properties and behavior.


The composition of the object: 1, attribute (member variable): Access modifier
Data type
Member Variable name

2. Behavior

JavaBean
1, there should be a common non-parametric structure
2, there should be a Get/set method that conforms to the naming specification.

Accessing the properties and methods of an object
Properties are part of an object and are contained within an object.
Access to the property is accessed through the object name, property name.


The purpose of the package:
Provides a mechanism for organizing classes.
Provides a namespace for the classes in the package.

Each executing method, at the top of the method call stack, is removed from the method whenever execution is complete.

The methods of the instance can access not only class variables and constants, but also variables in the instance.

The access modifier is independent of whether it is overloaded, whether the return type is the same or not, and whether the formal parameter name is the same as the overload.

In order, the type of formal parameter is different, it is considered to be different.

A constructor is a special method that is called to execute when a class creates an instance.
The name of the constructor must be the same as the class name. The constructor does not have a return type.
The constructor method is used to construct the object.
The construction method can also be called in the static method.


The role of the constructor
1 Allocating memory to objects
2 Creating and initializing member variables
3 return Reference

The constructor method can only be called with the New keyword.
Calling the parameterless construct must be in the first row of the constructor method.

Array
Each element in the array must be of the same data type.
An array is a contiguous memory space
The elements in the array are variables or literal constants.
The array element subscript starts at 0.
After the array is created, each element is initialized. An int has an initialization value of 0,double of 0.0, and the initial value of the reference type is full.
The length of the array cannot be changed.
The element type of an array is the type defined when the array is declared.

Array initialization
The array initializer does not need to use the New keyword when creating an array.
int [] a={1,2,3};

Array replication
System.arraycopy (source array scr,scrpos,dest,destpos,length);
When an array is copied, the source array should be smaller than the array to be copied.


Multidimensional arrays
Int[][]a=new Int[2][4];

This week's study began to feel the difficulty, the teacher speaks too fast, the thought cannot keep up.

Summary of the third week

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.