import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
//con 5 es sufi digo yo....
String[] lista = new String[40];
for (int x = 0; x < lista.length; x++) {
System.out.println("Intro Nombre y Apellidos: ");
String en = br.readLine();
if (en.length() > 0) {
lista[x] = en;
} else {
x--;
System.out.println("Nombre y apellidos VACÍO");
}
}
String e;
do {
System.out.println("Intro primera letra del nombre para buscar en la lista: (FIN para terminar)");
e = br.readLine();
if (e.equalsIgnoreCase("fin")) {
System.out.println("Me despido...");
} else if (e.length() > 0) {
for (String s : lista) {
if (s.toUpperCase().charAt(0) == e.toUpperCase().charAt(0)) {
System.out.println(s);
}
}
} else {
System.out.println("Debes introducir un valor...");
}
} while (!e.equalsIgnoreCase("fin"));
}
}
[/aux_code]
Lista de una clase
con
No hay comentarios
[aux_code language=»javascript» theme=»tomorrow» title=»Lista de una clase» extra_classes=»»]