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 ...
随机推荐
- BZOJ - 2500 树形DP乱搞
题意:给出一棵树,两个给给的人在第\(i\)天会从节点\(i\)沿着最长路径走,求最长的连续天数\([L,R]\)使得\([L,R]\)为起点的最长路径极差不超过m 求\(1\)到\(n\)的最长路经 ...
- CentOS开放端口号
#vi /etc/sysconfig/iptables 在打开的文件中增加一份端口配置信息: A INPUT -p tcp -m state --state NEW -m tcp --dport 81 ...
- mono for android读书笔记之真机调试(转)
调试环境: 1.软件:monodevelop v3.0.3.5 2.硬件:华为C8650s手机一部,数据线一根,thinkpad e420笔记本电脑一台 调试的应用程序有一个Activity,Acti ...
- php-redis 模块 文档
直接从这位朋友转载过来. 地址 Redis::__construct构造函数$redis = new Redis(); connect, open 链接redis服务参数host: string,服务 ...
- 19.Class的基本语法
1.简介 JavaScript 语言中,生成实例对象的传统方法是通过构造函数. function Point(x, y) { this.x = x; this.y = y; } Point.proto ...
- Git的常用撤销技巧与解决冲突方法
git checkout . #本地所有修改的.没有的提交的,都返回到原来的状态 git stash #把所有没有提交的修改暂存到stash里面.可用git stash pop回复. git rese ...
- Scrum 冲刺博客第六篇
一.当天站立式会议照片一张 二.每个人的工作 (有work item 的ID),并将其记录在码云项目管理中 昨天已完成的工作 判断用户输入的答案是否正确并将其输出到界面中 今天计划完成的工作 对排行榜 ...
- 基于标注的AOP面向切面编程
1.什么是AOP Aspect Orientied Programming的简称,即 面向(方面)切面编程 ,不改变一个组件源代码的情况下 可以对组件功能进行增强. 例如:servlet中的过滤 ...
- spring mongodb增删改查操作
添加数据 School @Id @GeneratedValue private long id; @Indexed(unique = true) private String name; studen ...
- asp.netCore连接多个数据库
1.首先要有对应的context实体类, 多个实体类的构造函数的参数都应该是集合 public class firstContext : DbContext { //多个数据库应该使用这个构造函数,参 ...