swapattempt.java

来自「java 完全探索的随书源码」· Java 代码 · 共 21 行

JAVA
21
字号
public class SwapAttempt {  public static void swap( String s1, String s2 ) {    // these statements are legal but they have no    // effect on the variables in the calling method    String temp = s1;    s1 = s2;    s2 = temp;  }  public static void main( String args[] ) {    String s1 = "First String";    String s2 = "Second String";    swap(s1, s2);    // the object references are unchanged    System.out.println("After the swap");    System.out.println("s1 is " + s1);    System.out.println("s2 is " + s2);  }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?