You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

13 lines
394 B

package w7;
public class Test {
public static void main(String[] args) {
// 原始 Pair
Pair<String, Integer> original = new Pair<>("年龄", 18);
System.out.println("交换前:" + original);
// 调用静态 swap 方法交换键值
Pair<Integer, String> swapped = Pair.swap(original);
System.out.println("交换后:" + swapped);
}
}