views:

80

answers:

1

hi all, it's first time for me I use java I need to use a stack in android funcions but if I define the stack out of the function give me the error (should be parametrized) and the application crashes

public class Televideo extends Activity{
    Stack pila = new Stack();

    @Override
    public void onCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        pila.push(mystring);
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item){
        mystring = pila.peek();
    }
}

how can I use the stack through class functions in java? thanks

+2  A: 

parametrising means that you tell the Class (in this case your Stack) what type of objects its instance (in this case pila) will contain. Try this code instead of yours:

Stack<String> pila = new Stack<String>()

However, this should not be an error but only a warning as far as I know.

delirium