Hi! I don't understand why the line related with "While" and "nextLine" does not work, also there is message that says "resorce leak: 'en' is never closed". thanks in advance. This my code:
package inicial; import java.util.Scanner; public class Iniciales { public static void main(String[] args) { Scanner en = new Scanner(System.in); System.out.println("Escribe tu nombre"); String miNombre; miNombre = en.nextLine(); String e=" ", ini=""; int c=0; char i; char espacio=e.charAt(0); while(c<miNombre.length()){ i=miNombre.charAt(c); if((c==0) && (i != espacio)) { ini=ini+i; }else { do { c++; }while(i != espacio); c++; ini = ini + i; } } System.out.println("Tus iniciales son: " + ini); } }