The formal parameters of the method
package basic.java;
public class ParametersOfTheMethod {
public static void main(String[] args) {
int a = 10;
int b = 20;
System.out.println(a + "===" + b);
change(a, b);
System.out.println(a + "===" + b);
}
public static void change(int a, int b) {
// TODO Auto-generated method stub
System.out.println(a + "===" + b);
a = b;
b = a + b;
System.out.println(a + "===" + b);
}
}

如果方法的参数是基本数据类型:形式参数的改变不影响实际参数。
package basic.java;
public class ArgsDemo2 {
public static void main(String[] args) {
int arr[] = { 1, 2, 3, 4, 5 };
for (int i = 0; i < arr.length; i++) {
System.out.println(arr[i]);
}
change(arr);
for (int i = 0; i < arr.length; i++) {
System.out.println(arr[i]);
}
}
public static void change(int[] arr) {
// TODO Auto-generated method stub
for (int i = 0; i < arr.length; i++) {
if (0 == arr[i] % 2) {
arr[i] *= 2;
}
}
}
}

如果参数是引用数据类型:形式参数的改变直接影响实际参数。
The formal parameters of the method的更多相关文章
- JVM Specification 9th Edition (4) Chapter 4. The class File Format
Chapter 4. The class File Format Table of Contents 4.1. The ClassFile Structure 4.2. Names 4.2.1. Bi ...
- Java Exception & RTTI
Exception Try { ... ... } catch (Exception ex) { …; throw new Throwable(ex); } catch (Throwable ex) ...
- Part 67 to 70 Talking about method parameters in C#
Part 67 Optional parameters in c# Part 68 Making method parameters optional using method overloadin ...
- 【反射】Reflect Class Field Method Constructor
关于反射 Reflection 面试题,什么是反射(反射的概念)? 主要是指程序可以访问,检测和修改它本身状态或行为的一种能力,并能根据自身行为的状态和结果,调整或修改应用所描述行为的状态和相关的语义 ...
- The method newInstance() from the type Class is deprecated since version 9
newInstance()在 java9中已被弃用 JAVA9之前用法 Class.forName("类的全限定名").newInstance(); JAVA9之后用法 Class ...
- passing parameters by value is inefficient when the parameters represent large blocks of data
Computer Science An Overview _J. Glenn Brookshear _11th Edition_C Note that passing parameters by va ...
- [Hapi.js] Route parameters
Routing is a fundamental aspect of any framework. In this lesson, you'll learn how to use path param ...
- Supported method argument types Spring MVC
Supported method argument types The following are the supported method arguments: Request or respons ...
- formal parameter
formal parameter : [3.16] object declared as part of a function declaration or definition that acqui ...
随机推荐
- Python:学习遇到的小问题:记事本写的脚本执行提示SystaxError:(unicode error) 'utf-8'
学习了一段时间的Python因为懒没有坚持,现在又想学,在用记事本写好py脚本运行时报错:SystaxError:(unicode error) 'utf-8' 解决的方法: 因为我的笔记本系统自带的 ...
- 洛谷 P3757 [CQOI2017]老C的键盘
题面 luogu 题解 其实就是一颗二叉树 我们假设左儿子小于根,右儿子大于根 考虑树形\(dp\) \(f[u][i]\)表示以\(u\)为根的子树,\(u\)为第\(i\)小 那么考虑子树合并 其 ...
- python实现计算器功能
import re def strip_operate(exp): # 合并多余的操作符 exp = exp.replace("+-", "-") exp = ...
- OPENERP 新添模块后导致启动不了的问题总结
自己新的的模块在本地运行OK,上传到服务器后,导致所有用户登录不了,并报“ProgrammingError: column “” does not exist”不存在的错误. 错误原因,自定义模块发生 ...
- (转)mysql 备份与恢复mysqlhotcopy
原文:http://fuwenchao.blog.51cto.com/6008712/1331910 mysqlhotcopy是一个Perl脚本,最初由Tim Bunce编写并提供.它使用LOCK T ...
- wampserver实现外网访问
1.打开运行WampServer3.0.4,鼠标移到wampserver上去,单击右键,出来个wamp Settings, 按照如图所示,选择Menu item : Online / Offline. ...
- 当spring抛出异常时出现的页面的@ExceptionHandler(RuntimeException.class) 用法
当spring抛出异常时出现的页面的@ExceptionHandler(RuntimeException.class) 用法 主要用在Controller层 @ExceptionHandler(Run ...
- 2-8 js基础 jsonp封装
'use strict'; function jsonp(json){ json = json||{} if(!json.url)return; json.data=json.data||{}; js ...
- 数据库分库分表(一)常见分布式主键ID生成策略
主键生成策略 系统唯一ID是我们在设计一个系统的时候常常会遇见的问题,下面介绍一些常见的ID生成策略. Sequence ID UUID GUID COMB Snowflake 最开始的自增ID为了实 ...
- java多线程---------java.util.concurrent并发包
所有已知相关的接口 1.BlockingDeque<E> 2.BlockingQueue<E> 3.Callable<V> 4.CompletionService& ...