# 原地址
https://leetcode-cn.com/problems/reverse-linked-list/
# 思路
这道题比较简单,大概思路就是遍历一遍,把节点指向新的链表节点。
# 代码
```java
/**
* Definition for singly-linked list.
* public class ListNode {
* int val;
* ListNode next;
* ListNode() {}
* ListNode(int val) { this.val = val; }
* ListNode(int val, ListNode next) { this.val = val; this.next = next; }
* }
*/
class Solution {
public ListNode reverseList(ListNode head) {
ListNode root = null;
while(head != null){
ListNode headNext = head.next;
head.next = root;
root = head;
head = headNext;
}
return root;
}
}
```

206. 反转链表 (链表)