error: illegal start of type

后端 未结 3 1927
渐次进展
渐次进展 2021-01-07 15:48

why this little piece of code is giving illegal start of type error in line 6 and 10(for loops).... i can\'t find any unmatched braces...

class StackDemo{
           


        
3条回答
  •  情歌与酒
    2021-01-07 16:15

    You cannot use for loop inside a class body, you need to put them in some kind of method.

    class StackDemo{
    final int size = 10;
    Stack s = new Stack(size);
    public void run(){
       //Push charecters into the stack
       for(int i=0; i

提交回复
热议问题