Why do I need an identifier for a for for loop when variables are already declared?

Can someone tell me what happened to mine for loop? I spent a lot of time trial and error and research on the Internet, but I still can not find a solution. He goes on to say that the expected identifier cannot find the character. Please help, thanks!

package imageviewer;

import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Scanner;
import java.util.Vector;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;

public class ImageViewer extends JPanel implements ActionListener {

    JPanel bottomPanel;
    JLabel imageLabel;
    JButton previousBtn;
    JButton nxtBtn;

    ImageViewer()
    {
        imageLabel = new JLabel("Image Display");
        imageLabel.setBackground(Color.WHITE);
        imageLabel.setOpaque(true);
        add(imageLabel);

        previousBtn = new JButton("Previous");
        previousBtn.addActionListener(this);
        add(previousBtn);

        nxtBtn = new JButton("Next");
        nxtBtn.addActionListener(this);
        add(nxtBtn);
    }

    String userInput = JOptionPane.showInputDialog("Please input name of first image file");
    Scanner myScanner = new Scanner(userInput);
    String fileDetail = myScanner.next();
    String[] arr = fileDetail.split("\\.");

    String fileName = arr[0].replaceAll("[0-9.]", "");
    String fileNumber = arr[0].replaceAll("[^0-9]", "");
    String fileFormat = arr[1];

    int num = Integer.parseInt(fileNumber);

    String totalImage = JOptionPane.showInputDialog("Please enter the number of images in total");
    Scanner secondScanner = new Scanner(totalImage);
    int numberInput = secondScanner.nextInt();

    ImageIcon imageGraphic = new ImageIcon(fileName + fileNumber + "." + fileFormat);

    Vector <String> imageDetail = new Vector <String>();
    int total = (num + numberInput);

    for(int i = num; i < total; i++)
    {
    }


public void actionPerformed(ActionEvent e)
    {
    }

}
+4
source share
3 answers

, , , , , .., for . : , , , .

, , " ", , JOptionPane, , , . - . .

, , , , . , , , . , , , , , .

+5

. , .. .

+2

for, , . , .

+1

Source: https://habr.com/ru/post/1548693/


All Articles