Home >Java >javaTutorial >How to use array as parameter of method in java

How to use array as parameter of method in java

WBOY
WBOYforward
2023-05-27 09:37:051697browse

Array as method parameter

Basic usage

JVM brief introduction

How to use array as parameter of method in java

How to use array as parameter of method in java

Partial Storage of variables in memory:

How to use array as parameter of method in java

The reference does not point to the object. Writing method:

How to use array as parameter of method in java

This reference does not point to any object.

How to use array as parameter of method in java

Can a reference point to multiple objects at the same time?

How to use array as parameter of method in java

For this code, it can only point to one object and store the address of an object. In the end, only the address of the last object is saved.

The process of passing the array as a parameter of the method:

How to use array as parameter of method in java

Solution and printing results:

before Two solutions:

How to use array as parameter of method in java

fun2 Print result:

How to use array as parameter of method in java

##Analysis example: What does the picture below represent

How to use array as parameter of method in java

represents the reference of array2, pointing to the object pointed to by the reference of array1.

The following picture represents the meaning of the above example:

How to use array as parameter of method in java

Note:

The quote points to the quote. This sentence is wrong. References can only point to objects

Does the reference have to be on the stack?

Not necessarily. Whether a variable is on the stack is determined by the nature of your variable. If it is a local variable, it must be on the stack. If not, for example, instance member variables are not necessarily on the stack.

The above is the detailed content of How to use array as parameter of method in java. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete