![643208-20160218040802081-562772347.png](https://i-blog.csdnimg.cn/blog_migrate/bff71e053d5af22a9a510d7c9675a808.png)
Implementation
/**
* Definition for singly-linked list.
* public class ListNode {
* int val;
* ListNode next;
* ListNode(int x) { val = x; }
* }
*/
public class Solution {
public ListNode swapPairs(ListNode head) {
ListNode dummy = new ListNode(0);
dummy.next = head;
ListNode current = dummy;
while (current.next != null && current.next.next != null) {
ListNode p1 = current.next;
ListNode p2 = current.next.next;
p1.next = p2.next;
p2.next = p1;
current.next = p2;
current = p1;
}
return dummy.next;
}
}