Faculty of Engineering and Mathematical Sciences 
Not logged in (login)

help2200


This forum is provided to promote discussion amongst students enrolled in Data Structures and Algorithms (CITS2200).
 
Options:
RSS cloud
Jump to:

previous()

3 of 251 articles shown, currently no other people reading this forum.
photo
From: ANONYMOUS
Date: Wed 1st Apr, 4:27pm
Actions: 
        Login-to-reply
Hello for the submission of lab 4, previous() is causing an error. I have left it 
blank,overrode it in Eclipse and also just copied the code from the lecture slides. Is 
this intended as I thought we were not meant to complete the method. 

previous()

photo
From: ANONYMOUS
Date: Fri 3rd Apr, 4:08pm
Actions: 
        Login-to-reply
Same issue here, here's the error message:

java.lang.NullPointerException
	at ListLinked.previous(ListLinked.java:162)
	at Lab4.main(Lab4.java:141)

previous()

photo
From: ANONYMOUS
Date: Fri 3rd Apr, 4:47pm
Actions: 
        Login-to-reply
I think I've figured it out. It was a problem with the delete method - I wasn't accounting 
for the deletion of the last object in the list, I was just setting the successor as usual.

I was testing the previous and next methods to try find the problem and I found that when i 
deleted an object at the end of the list, went back one and forward one, I was pointing to 
null instead of throwing an exception.

Not quite sure why the previous method was the one that had the "error" and still not 
certain it's correct, but it seems to be.
This Page


Program written by: [email protected]
Feedback welcome
Last modified:  8:27am May 24 2020