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 ...
随机推荐
- 达人篇:6.3)试验设计DOE,Design of Experiments
本章目的:了解DOE,结构工程师为什么学习DOE. 1.前言:结构工程师为什么要学DOE 作者作为一名结构工程师,为什么要学习DOE. 很简单,在第四版FMEA手册中,DOE是重要的探测控制手段.如图 ...
- 论文分享NO.3(by_xiaojian)
论文分享第三期-2019.03.29 Fully convolutional networks for semantic segmentation,CVPR 2015,FCN 一.全连接层与全局平均池 ...
- Gradle学习系列(二)
AS的逐渐成熟和完善,已有越来越多的项目开发都开始转向AS了,必然的对Gradel的认识和使用是很有必要了.我们已经知道 Gradle 是用来架构 Java项目了,对于Android Project来 ...
- dotnet core webapi +vue 搭建前后端完全分离web架构(一)
架构 服务端采用 dotnet core webapi 前端采用: Vue + router +elementUI+axios 问题 使用前后端完全分离的架构,首先遇到的问题肯定是跨域访问.前后端可 ...
- 【Kafka】Producer配置
名称 描述 类型 默认值 bootstrap.servers kafka集群地址,ip+端口,以逗号隔开.不管这边配置的是什么服务器,客户端会使用所有的服务器.配置的列表只会影响初始发现所有主机.配置 ...
- Microsoft Power BI Desktop概念学习系列之Microsoft Power BI Desktop是什么?
不多说,直接上干货! 官网 https://powerbi.microsoft.com/zh-cn/desktop/ Microsoft Power BI Desktop是什么? https://p ...
- Ubuntu14.04下Cloudera安装搭建部署大数据集群(图文分五大步详解)(博主强烈推荐)(在线或离线)
第一步: Cloudera Manager安装之Cloudera Manager安装前准备(Ubuntu14.04)(一) 第二步: Cloudera Manager安装之时间服务器和时间客户端(Ub ...
- redis集群的搭建详细教程
1 Redis-cluster架构图 redis-cluster投票:容错 (至少要三个才可以,才能超过半数) 架构细节: (1)所有的redis节点彼此互联(PING-PO ...
- android开发之提高应用启动速度_splash页面瞬间响应_避免APP启动闪白屏
Application和Activity中的onCreate都进行了优化,基本没有耗时操作,但是启动应用之后还是会闪现一下白色背景,然后才进入Splash页面,对比了一下QQ.微信.微博等客户端,点击 ...
- 几个用Python实现的简单算法
一.算法题目:有1.2.3.4个数字,能组成多少个互不相同且无重复数字的三位数?都是多少? 程序分析:可填在百位.十位.个位的数字都是1.2.3.4.组成所有的排列后再去 掉不满足条件的排列. 程序源 ...