Code does not compile with multiple errors

0
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 );
     }
}
    
asked by anonymous 13.12.2015 / 03:55

1 answer

4

Missing declare method, without it it will not even work.

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);
        }
    }
}

See running on ideone .

    
13.12.2015 / 04:38