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. hdu 3709 Balanced Number(平衡数)--数位dp

    Balanced Number Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others) ...

  2. apache访问快捷方式

    <VirtualHost *:80> DocumentRoot "XXX" ServerName XXX Alias /pdodata/  "XXX" ...

  3. 【ORACLE】ORACLE session(会话)管理

    #查看当前不为空的连接select * from v$session where username is not null #查看不同用户的连接数 select username,count(user ...

  4. html网页如何传递接收地址参数?

    实现html页面的参数传递 方法一: 下面是javascrīpt的一种实现方法, 这个函数是通过window.location.href中的分割符获得各个参数. 有了这个函数,就可以在页面之间传递参数 ...

  5. hibernate的AnnotationHelloWorld

    来龙去脉: 最开始sun这个土鳖设计了EJB2.0.EJB2.1那个时代.后来有人发现设计的很烂,不好用,就设计了hibernate,,人们发现用hibernate反而比EJB2.0.2.1好,hib ...

  6. 【开源组件】FastDFS极速入门与安装

    FastDFS是一个开源的轻量级的分布式文件系统,为互联网量身定制,充分考虑了冗余备份.负载均衡.线性扩容等机制,并注重高可用.高性能等指标,使用FastDFS很容易搭建一套高性能的文件服务器集群提供 ...

  7. JQuery Div scrollTop ScrollHeight

    jQuery 里和滚动条有关的概念很多,但是有三个属性和滚动条的拖动有关,就是:scrollTop.scrollLeft.scrollHeight.其中 scrollHeight 属性,互联网上几乎搜 ...

  8. WordPress主题开发:为文章添加自定义栏目

    开启自定义栏目:点击头顶的“显示选项”,勾选“自定义栏目” 然后编辑文章时,即可看见 实验: 定义名称为:play_url ,值为:http://www.xiami.com/widget/635357 ...

  9. table 中的tr 行点击 变换颜色背景

    <style> table{border-collapse: collapse;border-spacing: 0; width: 100%;} table tr th,td{border ...

  10. winform httplicent调用API

    绑定datagriview Uri uri = new Uri("http://localhost:49423");//地址            HttpClient clien ...