0

Here is the complete code:

import java.util.Scanner;

public class fila {

public static void main(String[] args) {
    //instanciando objeto fila: 
    FilaComum fila = new FilaComum();
    
    Scanner s = new Scanner(System.in);
    
    while ( fila.isEmpty()) {
        for (int i=0; i<10; i++) {
            System.out.println("Insira um valor: ");
            fila.inserir(s.nextInt());
        }
        s.close();
    }
    
    
    while (! fila.isEmpty()) {
        int valor = fila.retirar();
        System.out.println("Retirei o elemento: "+valor);
    }
}


public static class FilaComum { // LINE I'M REFFERING TO

    
    
    int[] valores;
    int primeiro=0;
    int ultimo=0;
    int total=0;
    
    
    
    //Método Construtor
    //Fila vazia
    public FilaComum(){
        valores = new int[10];
    ...
            ... etc

I would like to understand the reason for this error and what is the purpose of "static" in this case of the class

  • 1
    You define your `FilaComum` class inside of the class `fila`. Without making it `static`, you would need an instance of `fila` to create an instance of `FilaComum`. – f1sh Apr 13 '23 at 17:00

0 Answers0