"illegal start of Expression" when compiling on CMD

Asked

Viewed 57 times

4

I have the mini program, which I will show you next. When compiling at the command prompt, I got an error on line 47 which says:

illegal start of Expression

I have in the program a list of entries of the size defined in ListaArray. Code:

import java.util.*;

public class NívelDePontos
{

   private static int identificar(Scanner kb, String mensagem, String mensagemErro) 
   {
        while (true) 
        {
            System.out.println(mensagem);
            try 
            {
                return Integer.parseInt(kb.nextLine());
            } 
            catch (NumberFormatException e) 
            {
                System.out.println(mensagemErro);
            }
        }
    }

    private static boolean lerSimNao(Scanner kb, String mensagem, String mensagemErro) 
    {
        while (true) 
       {
            System.out.println(mensagem);
            String x = kb.nextLine();
            if (x.equalsIgnoreCase("S")) return true;
            if (x.equalsIgnoreCase("N")) return false;
            System.out.println(mensagemErro);
        }
    }

    public static void main(String[] args) 
    {
        Scanner kb = new Scanner(System.in);
        {        
            int identidade = identificar(kb, "Introduza o número seu número de Telefone ou ID Thumba ", "Registamos um erro . Por favor, tente novamente.");
            System.out.println("Bem-vindo, utilizador" +" " + identidade + ".");

             int count, msg, nivel1;
             int[] ListaArray;   ListaArray = new int[100];

             while(msg <= nivel1)
             {
                 count = msg;
                 count++;
                 return <count>;            
             }

             System.out.println("Obrigado, até a próxima.");
        }
    }
}
  • 3

    Whenever you get an error, also enter where is the error line, you say line 47 but where is line 47?

  • return <count>; This section has a syntax error, the right one is just return count;

1 answer

1

As @diegofm said, the syntax is:

return count;

Would be simpler

return msg + 1;

if you consider that you are matching the value of Count at the top line. You may have a logic problem the way the code was built.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.