Trying to instantiate objects within for loop and failing

后端 未结 4 585
暗喜
暗喜 2021-01-29 08:40

Basically I am trying to create a new class as long as the continue variable equals \"Y\". The problem I am having is

DigitalMain.java:18: not a statement
    D         


        
4条回答
  •  無奈伤痛
    2021-01-29 09:04

    class is a keyword - you can't use it as a variable name.

    Additionally, you have an odd construct here:

    for(int i=0; cont.equals("Y") ; i++)
    {
        ...
    } while {continue.equalsIgnoreCase(Y)};
    

    There's no such thing as a "for/while" loop - there's a normal for loop, a while loop, and a do/while loop.

    So you've actually got a for loop followed by an invalid while loop here. It has no condition.

    You need to work out which you want. (Possibly a for loop containing a do/while loop, although I'd extract the inner loop into a separate method. In general your code would greatly benefit from being broken out into multiple methods.

    You do something similar later, although this time with do/while:

    do
    {
        ...
    } while {bitps > 0 && bitps < 99999999};
    

    The condition of a while loop goes in round brackets, not braces:

    do
    {
        ...
    } while (bitps > 0 && bitps < 99999999);
    

    Basically, you should read up on the syntax options available for loops.

提交回复
热议问题