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 ...
随机推荐
- error occurred during initialization of vm
虚拟机无法进行如下分配 : -Xmx2048m -XX:MaxPermSize=512m 原因是我的老爷机总共内存只有3G: settings - > 搜索VM ->找到Compiler ...
- Array flat的实现
if (!Array.prototype.flat) { Array.prototype.flat = function (num = 1) { if (!Number(num) || Number( ...
- 在windows上部署使用Redis--资料整理
声明:一下只是针对windows系统,其他系统资料需自己补全. 很简单:下载.安装.安装桌面管理工具.测试.细不具表,下面几个网址应该足以解决你的所有问题. 网址访问专用Host: http://pa ...
- VMware Workstation中虚拟机的克隆
1 克隆虚拟机 首先需要准备好一个安装好的系统,这里以linux为例进行演示. 在需要克隆的机器上右键选择管理==>克隆 选择需要克隆的虚拟机的状态,如果你想要的就是当前的状态,就直接选择虚拟机 ...
- display:block、inline、inline-block的区别及应用案例
A.display:block就是将元素显示为块级元素. block元素的特点是: 1.总是在新行上开始: 2.高度,行高以及顶和底边距都可控制: 3.宽度缺省是它的容器的100%,除非设定一个宽度; ...
- 配置MySQL接受远程登录连接
一 开放mysql mysql的配置文件在/etc/mysql/my.cnf文件内,里面有一行bind-address = 127.0.0.1表示只允许本地访问,将这行注释即可 # bind-addr ...
- Spring MVC 使用kaptcha生成验证码
Spring MVC 使用kaptcha生成验证码 1.下载kaptcha-2.3.2.jar(或直接通过该文章附件下载) http://code.google.com/p/kaptcha/downl ...
- C#PrintDocument打印尺寸调整
/// <summary> /// 打印的按钮 /// </summary> /// <param name="sender"></par ...
- java 基础 --- java8 HashMap
问题 : HashMap 容量大小 (capacity)为什么为 2n HashMap 是线程安全的吗,为什么 HashMap 既然有hash进行排位还需要equals()作用是什么 文章部分图片 ...
- 十四、curator recipes之DistributedAtomicLong
简介 和Java的AtomicLong没有太大的不同DistributedAtomicLong旨在分布式场景中维护一个Long类型的数据,你可以像普通单机环境一样来使用它. 官方文档:http://c ...