java基础学习日志--Stirng内存案例
2024-08-24 22:32:11
案例一:
public class test1 {
public static void mb_swap(String Str1,String Str2) {
String temp=Str1;
Str1=Str2;
Str2=temp;
}
public static void main(String[] arg) {
String str1="A";
String str2="B";
mb_swap(str1,str2);
System.out.print(str1+" "+str2);
}
}
输出str1与str2结果为“A”、“B”
案例二:
public static void mb_swap(String[] s) {
if (s.length < 2)
return;
String t = s[0];
s[0] = s[1];
s[1] = t;
}
public static void main(String[] arg) {
String[] s = { "1", "2" };
mb_swap(s);
System.out.print(s[0] + s[1]);
}
输出结果:21
最新文章
- Bootstrap-datetimepicker年月日
- pygal and matplotlib(again)
- js实现cookie记住密码
- ArangoDB介绍——未知架构和底层原理
- linux shell 当前时间
- lower_bound实现函数
- Android 中的 Service 全面总结 (转)
- TabControl控件中TabPage的显示和隐藏
- POJ 3208 Apocalypse Someday
- Intent.ACTION_TIME_TICK 广播
- 《how to design programs》12章函数复合
- linux之SQL语句简明教程---SELECT
- HDU 1950 Bridging signals (DP)
- CentOS安装glibc-2.14,错误安装libc.so.6丢失急救办法
- MySQL索引(1)
- Android开发——BroadcastReceiver广播的使用
- UNIX网络编程——带外数据小结
- C#将一个枚举里面所有描述和value绑定到下拉列表的方法
- CF822C Hacker, pack your bags!(思维)
- MySQL— 进阶