- package com.itheima01;
- public class StringDemo {
- String str = new String("good");
- char[] ch = { 'a', 'b', 'c' };
- Float fValue = Float.valueOf(12.3f);
- public static void main(String[] args) {
- StringDemo sd = new StringDemo();
- sd.change(sd.str, sd.ch);
- System.out.println(sd.str);// good
- System.out.println(sd.ch);// gbc
- String ss = "web";
- char[] chh = { 'c', 'd', 'e' };
- sd.change(ss, chh);
- System.out.println(ss);// web //不改变
- System.out.println(chh);// gde //改变
- sd.change(sd.fValue);
- System.out.println(sd.fValue);// 12.3没有改变
- int iValue = 123;
- change(iValue);
- System.out.println(iValue);// 123 不改变
- }
- private void change(String str, char[] ch) {
- str = "test ok";
- ch[0] = 'g';
- // ch[1] = 'h';
- }
- private static void change(float fValue) {
- fValue = 3.4f;
- }
- private static void change(int iValue) {
- iValue = 321;
- }
- }
复制代码 |