fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. Scanner scan = new Scanner(System.in);
  13.  
  14. String[] nomes = new String[3];
  15.  
  16. for (int i = 0; i < nomes.length; i++) {
  17. System.out.println("Digite o " + (i + 1) + "º nome: ");
  18. nomes[i] = scan.next();
  19. }
  20.  
  21. for (int i = 0; i < nomes.length; i++) {
  22. System.out.println(i + " - " + nomes[i]);
  23. }
  24. }
  25. }
Success #stdin #stdout 0.19s 53916KB
stdin
Fulano de Tal
stdout
Digite o 1º nome: 
Digite o 2º nome: 
Digite o 3º nome: 
0 - Fulano
1 - de
2 - Tal