Posted By:
habam_point
Posted On:
Wednesday, August 20, 2003 12:31 PM
Hi all ! The following Code snippet is an outtake of a program: --- private Object[] m_Stack; [...] public Stack() { m_Stack = new Object[100]; } public void push(Object obj1) { m_Stack[0] = obj1; } --- --- Testdriver --- Stack s1 = new Stack(); s1.push(new Integer(5)); I believe that this HAS TO WORK - but it doesnt. When i want to compile this then it says: Obj.java:18: push(Object) in Stack cannot be applied to (java.lang.Integer) s1.push(new Integer(5));
More>>
Hi all !
The following Code snippet is an outtake of a program:
---
private Object[] m_Stack;
[...]
public Stack() {
m_Stack = new Object[100];
}
public void push(Object obj1) {
m_Stack[0] = obj1;
}
---
--- Testdriver ---
Stack s1 = new Stack();
s1.push(new Integer(5));
I believe that this HAS TO WORK - but it doesnt.
When i want to compile this then it says:
Obj.java:18: push(Object) in Stack cannot be applied to (java.lang.Integer)
s1.push(new Integer(5));
So whats wrong here ?
Greets,
Jim
<<Less