Code does not compile with several errors

Asked

Viewed 106 times

-1

import java.util.Arrays;

public class OrdenaArgumentos {
    String [] nomes = new String []{ " rafael cosentino ", " jonas hirata ", " marcelo martins "};
    java.util.Arrays.sort (nomes);

     for ( String nome : nomes ) {
     System . out. println ( nome );
     }
}
  • 2

    Could you add more information about the problem?

  • Multiple markers at this line - Syntax error on token ";", { expected after this token - Syntax error, Insert "... Variabledeclaratorid" to complete Formalparameterlist - Syntax error on token(s), misplaced Construct(s)

  • Syntax errors in the sentence java.util.Arrays.Sort (names);

  • The point of . Sort is underlined in red and (names); also.

  • You can always Edit your question to add this and other relevant additional information that may help solve the problem. The edit link is just below your question after tags. If you need help formatting text and code, go to: Help on the Markdown and also - format publications

1 answer

5


Failed to declare the method, without it will not work even.

import java.util.Arrays;

class OrdenaArgumentos {
    public static void main(String[] args) {
        String [] nomes = new String []{ " rafael cosentino ", " jonas hirata ", " marcelo martins "};
        java.util.Arrays.sort(nomes);
        for (String nome : nomes) System.out.println(nome);
    }
}

Behold working in the ideone. And in the repl it.. Also put on the Github for future reference.

Browser other questions tagged

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