Yeah I thought of doing that but then the issue is, he wants the index number to be displayed correspondingly. I got the get() working, so I can just For loop it and run up the index number to the...
Type: Posts; User: _lithium_
Yeah I thought of doing that but then the issue is, he wants the index number to be displayed correspondingly. I got the get() working, so I can just For loop it and run up the index number to the...
The main final task is to display what is left in the LinkedList, I'm just struggling to find an easy solution without actually just programming it into the code to say the actual ones that I know...
import java.util.*;
public class GenericStack<E>
{
private LinkedList<E> list = new LinkedList<E>();
public void push(E item) //the parameter is an item of type E
{
...
Well I've been trying to get the get() method working but keep getting errors with the:
public int get(E item)
{
return list.get(item);
}
I can't figure out how to basically get the index...
EDIT:::
Got it, I'm dumb and forgot the -1 indicates that the value wasn't found. Forgot to place the index call after the push().
Since I am supposed to be able to find the index number of the item, I know I need to use the indexOf() but can't figure out how to implement it into my app.
public int index(E item)
{...
Any idea on how to configure peek()?
That worked like a charm! thank you!
:::EDIT:::
How do I use the peek() then?
Lol, I can't figure out how to get it to send me back the size or in fact, I can't figure out ANY of the peek(),pop(),size()...
So I'm completely stumped..
this is the goal:
1. Start a new class named GenericStack that specifies a type variable that provides for generics.
2. Declare a linked list that will hold the...