不能出現第三個中間變量,字符串的交換

今天百度知道遇到知友的提問,是這個問題,所以就回答了下。

1
2
3
4
5
6
7
8
9
10
public class Test24 
    public static void main(String... args) { 
        //abcdeabcd 
        String str1 = "abcd";  // abcdefg 
        String str2 = "abcdeeeabcd"
        str1 = ( str2 + str1 ).substring(0,(str2 + ( str2 = str1)).lastIndexOf(str1)) ; 
        System.out.println("str1: " + str1 + "," "str2: " + str2); 
    
}
1
2
3
4
5
6
7
//author kf156 
   
String str1 = "abcd";  
String str2 = "efg"
str1 = str2 + ((str2 = str1) == null "" ""); 
System.out.println(str1); 
System.out.println(str2);
1
2
3
4
5
6
7
//haojia0716
 
String s1 = "123";
String s2 = "456";
s1 = s2 + (s2 = s1).replaceAll(".""");
System.out.println(s1);
System.out.println(s2);

獲取【下載地址】

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章