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的更多相关文章

  1. 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 ...

  2. Java Exception & RTTI

    Exception Try { ... ... } catch (Exception ex) { …; throw new Throwable(ex); } catch (Throwable ex) ...

  3. 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 ...

  4. 【反射】Reflect Class Field Method Constructor

    关于反射 Reflection 面试题,什么是反射(反射的概念)? 主要是指程序可以访问,检测和修改它本身状态或行为的一种能力,并能根据自身行为的状态和结果,调整或修改应用所描述行为的状态和相关的语义 ...

  5. The method newInstance() from the type Class is deprecated since version 9

    newInstance()在 java9中已被弃用 JAVA9之前用法 Class.forName("类的全限定名").newInstance(); JAVA9之后用法 Class ...

  6. 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 ...

  7. [Hapi.js] Route parameters

    Routing is a fundamental aspect of any framework. In this lesson, you'll learn how to use path param ...

  8. Supported method argument types Spring MVC

    Supported method argument types The following are the supported method arguments: Request or respons ...

  9. formal parameter

    formal parameter : [3.16] object declared as part of a function declaration or definition that acqui ...

随机推荐

  1. F6&F7adjust the volume

    Windows Registry Editor Version 5.00[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard La ...

  2. Chrome获取微信授权,调试公众号页面

    1.目的 你可能遇到过这种情况,在微信中打开公众号是这样的. 复制链接,在chrome中打开是这样的. 博主今天要解决的就是,如果在chrome中加载需要微信授权的页面,至于加载成功后要干嘛,测试?抓 ...

  3. PHP 导入数据库 sql 文件

    使用PHP 可以导入sql来建立数据库.代码如下: <?php $hostname = 'localhost'; $dbname = 'test'; $username = 'root'; $p ...

  4. CentOS7服务管理(重启,停止,自动启动命令)

    我们对service和chkconfig两个命令都不陌生,systemctl 是管制服务的主要工具, 它整合了chkconfig 与 service功能于一体. systemctl is-enable ...

  5. python-TCP模拟ftp文件传输

    #!/usr/bin/python #coding=utf-8 #server from socket import* import sys,os def command(): l=[ "W ...

  6. golang reflect包使用解析

    golang reflect包使用解析 参考 Go反射编码 2个重要的类型 Type Value 其中Type是interface类型,Value是struct类型,意识到这一点很重要 Type和Va ...

  7. jQuery插件开发之datalist

    HTML5中定义了一种input框很好看的下拉列表--datalist,然而目前它的支持性并不好(万恶的IE,好在你要渐渐退役了...).于是最近更据需求写了一个小型datalist插件,兼容到IE8 ...

  8. Nginx教程(五) Nginx配置文件详解

    一. Nginx配置文件nginx.conf中文详解 #定义Nginx运行的用户和用户组 user www www; #nginx进程数,建议设置为等于CPU总核心数. worker_processe ...

  9. 虚拟机下的zookeeper集群安装

    ZooKeeper是一个分布式的,开放源码的分布式应用程序协调服务,是Google的Chubby一个开源的实现,是Hadoop和Hbase的重要组件.它是一个为分布式应用提供一致性服务的软件,提供的功 ...

  10. android studio导入android studio工程

    在导入其他android studio工程的时候因为gradle和sdk.tool等版本不一样,会导致android studio自动去后台下载,导致占用硬盘越来越大,最主要的时候会等待很久,不知道要 ...