java中参数传递
2015-10-27 22:08
323 查看
package com.cc;
public class Hello {
public static void main(String[] args) {
String a = "String";
StringBuffer b = new StringBuffer("StringBuffer");
methodA(a);
methodB(b);
System.out.println(a);//String
System.out.println(b);//StringBuffer
int c = 10;
methodC(c);
System.out.println(c);//10
}
public static void methodA(String str){
str = new String("newString");
System.out.println("methodA中 : " + str);
}
public static void methodB(StringBuffer str){
str = new StringBuffer("newStringBuffer");
System.out.println("methodA中 : " + str);
}
public static void methodC(int i){
i = 20;
System.out.println("methodA中 : " + i);
}
}
public class Hello {
public static void main(String[] args) {
String a = "String";
StringBuffer b = new StringBuffer("StringBuffer");
methodA(a);
methodB(b);
System.out.println(a);//String
System.out.println(b);//StringBuffer
int c = 10;
methodC(c);
System.out.println(c);//10
}
public static void methodA(String str){
str = new String("newString");
System.out.println("methodA中 : " + str);
}
public static void methodB(StringBuffer str){
str = new StringBuffer("newStringBuffer");
System.out.println("methodA中 : " + str);
}
public static void methodC(int i){
i = 20;
System.out.println("methodA中 : " + i);
}
}
相关文章推荐
- 在java 中,数组与 List<T> 类型的相互转换
- fastdf使用例子(java版)
- java--对象比较器
- java Vamei快速教程12 类型转换和多态
- Java实现排序算法之冒泡排序
- java基础 集合框架 简单总结
- MyEclipse 10 集成Maven
- java --配置文件读取
- (转)SpringSecurity扩展User类,获取Session
- spring+mybatis多数据源配置
- Java:多线程之生产者与消费者
- java Vamei快速教程11 对象引用
- 矩阵------顺时针打印矩阵+顺时针旋转矩阵+之字形打印矩阵(Java)
- java工厂模式
- Eclipse 工作目录被破坏,导致Eclipse 打不开
- Java:多线程
- .以及JDK1.5ConcurrentHashMap新特性
- 记录-Head first java-1到3章
- java中Iterator和Iterable的区别
- Spring controller