Trying to instantiate objects within for loop and failing

后端 未结 4 550
暗喜
暗喜 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:06

    there is some rules for naming of variables Variables

     You cannot use any of the following(in list of keywords) as identifiers in your
     programs.The keywords const and goto are reserved, even though they are not 
     currently used. true, false, and null might seem like keywords, but they 
     are actually literals;      you cannot use them as identifiers in your programs.
    

    List of keywords

    for(int i=0; cont.equals("Y") ; i++)
     {
       class[i] = new DigitalPhoto();
       heightString = JOptionPane.showInputDialog('Please enter height');
       class[i].setHeight = double.parseDouble(heightString);
       heightString = JOptionPane.showInputDialog('Please enter width');
       class[i].setWidth = double.parseDouble(widthtString);
       continueQuestion = JOptionPane.showInputDialog('Height: ' + 
       class[i].getHeight + '\n\lWidth: ' + class[i].getWidth + '\n\l Resolution: ' +
       class[i].getResolution + '\n\lCompression Ratio: ' +  class[i].getCompression +
      '\n\lRequired Storage: ' + class[i].calcStorage() + '\n\lPrice of Scanned Photo: ' + 
        class[i].getCost() + 'Please enter "Y" to 
       try again or anything but "Y" to accept values.')
    } while {continue.equalsIgnoreCase(Y)};
    

    here i dont know any for-while loop..just check some basics..
    Loops in java

提交回复
热议问题