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.
21 lines
579 B
21 lines
579 B
package com.example.W8;
|
|
|
|
// 导入Pair类
|
|
import com.example.W8.Pair;
|
|
|
|
public class PairTest {
|
|
public static void main(String[] args) {
|
|
Pair<String, Integer> p1 = new Pair<>("小明", 18);
|
|
Pair<String, Integer> p2 = new Pair<>("小红", 19);
|
|
|
|
System.out.println("交换前:");
|
|
System.out.println("p1 = " + p1);
|
|
System.out.println("p2 = " + p2);
|
|
|
|
Pair.swap(p1, p2);
|
|
|
|
System.out.println("\n交换后:");
|
|
System.out.println("p1 = " + p1);
|
|
System.out.println("p2 = " + p2);
|
|
}
|
|
}
|
|
|