Files
hello-algo/ja/codes/java/utils/ListNode.java
Yudong Jin d7b2277d2b Re-translate the Japanese version (#1871)
* Retranslate Japanese docs with GPT-5.4

* Retranslate Japanese code with GPT-5.4
2026-03-30 07:30:15 +08:00

29 lines
607 B
Java

/**
* File: ListNode.java
* Created Time: 2022-11-25
* Author: krahets (krahets@163.com)
*/
package utils;
/* 連結リストノード */
public class ListNode {
public int val;
public ListNode next;
public ListNode(int x) {
val = x;
}
/* リストを連結リストにデシリアライズする */
public static ListNode arrToLinkedList(int[] arr) {
ListNode dum = new ListNode(0);
ListNode head = dum;
for (int val : arr) {
head.next = new ListNode(val);
head = head.next;
}
return dum.next;
}
}