• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Lame Java Question

bex0rs

Golden Member
This one is pretty basic, but for some reason I'm being kind of dense right now.

If I have a method, say removeLast() in the class LinkedList, which, according to Sun's specs, removes the last element from a LinkedList and returns it, does that mean I must do something like this:

Object blah = myLinkedList.removeLast();

or can I just do this:

myLinkedList.removeLast();

since I don't care about what the last object is. I just want to ditch it and there is no need to save it.

Thanks!

~bex0rs
 
yes what you should do then is the second choice since you dont care what the last element was then you may just want to discard the results. why even create another object to hold somethignthat you dont even want in the end. Although it may be needed later, but it just seems like you dont care about it so just ditch it.
hope that helps
 
That was what I was suspecting, and I just verified it. So I guess that even though removeLast() returns an Object, I don't need to explicitly code what to do with it. Thanks!

~bex0rs
 
beX0rs, how skilled are you @ java ??
I'm working w/ Cold Fusion & want to chat w/ someone about ways to utilize the 2 effectively.

shoot me a PM 🙂
 
if you don't give it (the returned object) an assignment in the current stack, it'll just be garbage collected, which is what you want to do anyways.
 
Back
Top