开发者

Stack in android

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){
        mys开发者_如何学Gotring = pila.peek();
    }
}

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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜