Custom Java stack class (with generics) problem in Java
Ok, so here are my classes and interfaces:
[code]public interface I_LinkedStack
public LinkedStack implements I_LinkedStack
-- private static class Node
-- private class LinkedListIterator implements java.util.Iterator
public Postfix
Postfix is a class with the following methods:
[code]public String iterableToString(Iterable
public String infixToPostfix(String infixExpression)
public int evaluatePostfix(String postfixExpression)[/code]
Everything is working fine with the exception of one thing. In my evaluatePostfix method I call iterableToString in order to print a stack declared locally within evaluatePostfix. Like this:
[code]LinkedStack
[...]
System.out.println(this.iterableToString(stack));[/code]
But I'm getting the following error:
[code]iterableToString(java.lang.Iterable
Why? LinkedStack is an iterable type, and Integer is just fine for T. It might also be worth noting that it compiles if I try to pass it String, Integer, or any other class like that.
Original post:
Custom Java stack class (with generics) problem in Java
04
