Java Fundamentals (Chapter 14)

Source: Internet
Author: User

Java Fundamentals (Chapter 14)

1. Packages (package) in Java

2.1 packages, corresponding to folders on disk

2.2 Create a new class that defaults to the default package

2.3 Declaring the Package keyword: packages

Package statement, pinned location

2.4 Importing a package keyword: import

Import package name. Class Name (* denotes all);

2.5 Effects:

Classify, resolve conflicting names, easily find and manage

2.6 Naming conventions

The Java package name is usually made up of lowercase letters and cannot start or end with a dot.

The prefix of a unique package name is usually all lowercase ascii letters, and is a top-level domain, COM, edu, gov, net, org, usually in reverse order with the organization's network domain name.

The subsequent parts of the package name vary according to the respective internal specifications of the different institutions.

2 . Methods with Parameters

Formal parameters: The salutation to a parameter when defining a method. Purpose: Defines the number and type of parameters that the method needs to pass in.

actual Parameters : The actual value that is passed to the method when the method is called.

When calling a method, note that:

The object is instantiated, the method is called, and the type, quantity, and order of the arguments correspond to the parameter one by one.

Formal parameters (formal parameter)

2.1 How to declare

Public return type method name (data type parameter name) {

.... Method body

}

2.2 Divided into 2 categories

2.2.1 No return type--void

2.2.2 has return type

L Basic Data types

L Custom Class-- The object of the return class ;

L Array--return array name ;

2.3 Types of parameters

L Basic Data type (10-31)

L Custom Class--passes the object of the class

L array--only the "array name" needs to be passed

2.4 Calls

2.4.1 called in the current class--Method name (value list);

2.4.2 called in other classes--object name. Method Name (value list);

Iii. Summary of methods

Classification:

1, no return type, no parameters

2, no return type, parameters

3, there is a return type, no parameters

4. There are both return types and parameters

parameter or return type, which can be a common data type or a custom class or array

Java Fundamentals (Chapter 14)

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.