forked from osmarsanchez/Proyectos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
arreglo.java
31 lines (27 loc) · 852 Bytes
/
arreglo.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import java.util.Scanner;
import javax.swing.JOptionPane;
/
*
* @author x
*/
public class Rellenar {
/
* @param args the command line arguments
*/
public static void main(String[] args) {
int elementos= Integer.parseInt(JOptionPane.showInputDialog("Ingresar numero de elementos"));
Scanner sc= new Scanner(System.in);
char[] letras = new char[elementos];
//Solicitar
System.out.println("Digite los elementos del arreglo: ");
for(int i=0;i<elementos;i++){
System.out.print((i+1)+". Digite un caracter:");
letras[i] = sc.next().charAt(0);//Guardar primer caracter --charArt
}
//Mostrar
System.out.println("\nLos caracteres son: ");
for(int i=0;i<elementos;i++){
System.out.print(letras[i]+ " ");
}
}
}