From 4827f0aac491b9937540bb358da5d9940eb6a9bb Mon Sep 17 00:00:00 2001 From: kacastillo <157073083+kacastillo@users.noreply.github.com> Date: Mon, 12 May 2025 13:43:57 -0700 Subject: [PATCH 1/2] Update ListNode.java --- src/ListNode.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ListNode.java b/src/ListNode.java index dd6028c..91fa9a8 100644 --- a/src/ListNode.java +++ b/src/ListNode.java @@ -1,3 +1,7 @@ public class ListNode { - + public int data; +public ListNode next; +public ListNode (int data) { +this. data = data; +} } \ No newline at end of file From e76e86b8e1c5e3b54e80b1faf264ddcc00785956 Mon Sep 17 00:00:00 2001 From: kacastillo <157073083+kacastillo@users.noreply.github.com> Date: Mon, 12 May 2025 13:50:14 -0700 Subject: [PATCH 2/2] Update Practice.java --- src/Practice.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/Practice.java b/src/Practice.java index 34a2f8d..f5ff250 100644 --- a/src/Practice.java +++ b/src/Practice.java @@ -1,5 +1,22 @@ public class Practice { public static void main(String[] args) { - + ListNode head = new ListNode (14); +ListNode MySeven = new ListNode(7); + + +// this sets head.next to MySeven value. +head.next = MySeven; +// this creates a new Node with a value +MySeven. next = new ListNode (28); +head.next.next = new ListNode (32); +head.next.next.next = new ListNode (23); +// System.out.println(head); +ListNode current = head; +int total = 0; +while (current != null) { +total += current.data; +current = current. next; +} +System.out.println(total); } }