Hi everyone this is my accepted Java solution. Since the list is sorted, so I did two while loops. Let me know if you have any suggestion :)

```
public ListNode deleteDuplicates(ListNode head) {
ListNode temp = head;
while (temp != null) {
while(temp.next != null && temp.next.val == temp.val) {
temp.next = temp.next.next;
}
temp = temp.next;
}
return head;
}
```