Lol i forgot to post the code....
import java.util.*;
public class Prob{
public static String insertar(){
Scanner sc = new Scanner(System.in);
LinkedList lista = new LinkedList();
System.out.println("Inserte nuevo estudiante");
lista.add("Dionis Matos/2002-0824/ISC");
lista.add(sc.next());
lista.add(sc.next());
lista.add("Perensejo de Tal/2003-1717/MER");
return lista;
}
public static void main(String args[]){
insertar();
}
}
[Hello again..
This time i've added a few more things to the mix... but the compiler now tells me that there's an illegal start of type, and also says "indentifier expected"
import java.util.*;
public class Uno{
public static String insertar(){
Scanner sc = new Scanner(System.in);
LinkedList lista = new LinkedList();
System.out.println("Inserte nuevo estudiante");
lista.add("Dionis Matos/2002-0824/ISC");
lista.add(sc.next());
lista.add("Perensejo de Tal/2003-1717/MER");
System.out.println(lista);
return " ";
}
public static void borrar(){
Scanner sca = new Scanner(System.in);
System.out.println("Desea borrar un estudiante de la lista? s/n");
String x = sca.next();
int y;
if(x.equals(s)){
System.out.println("Digite el numero del estudiante a borrar: 0 al 2");
int y = sca.nextInt();
if(y == 0){
lista.remove(0);
System.out.println(lista);
}
else if(y == 1 ){
lista.remove(1);
System.out.println(lista);
}
else if(y == 2){
lista.remove(2);
System.out.println(lista);
}
}
}// illegal start of type here
else{
System.out.print("No se borro ningun estudiante" + " " + lista);
}
public static void main(String args[]){
insertar();
borrar();
}
// Identifier expected here
}
How can i solve this?
Jebus wept! That's a terrible way to fix your first problem! If you're not interested in the return value of insertar(), don't give it a return type. I suspect, though, that you really want it to return a List instead
The other problem looks like you've just missed a closing bracket on that borrar method. But the whole thing just doesn't make sense, what are you actually trying to do?