Trying to instantiate objects within for loop and failing

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

    The issue is most likely the name of your array. The word class is a keyword in the Java language and hence cannot be used to name variables. You can also use ArrayLists like so:

    List photoes = new ArrayList(); 
    do
        {
        DigitalPhoto photo = new DigitalPhoto();
        heightString = JOptionPane.showInputDialog('Please enter height');
        photo .setHeight = double.parseDouble(heightString);
        heightString = JOptionPane.showInputDialog('Please enter width');
        photo .setWidth = double.parseDouble(widthtString);
        photos.add(photo)
        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 {cont.equals("Y")};
    

提交回复
热议问题