<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style></head>
<body class='hmmessage'><div dir='ltr'>
<span id="toBoxTo" style="display: block;"><span class="BlockEmailNoName">Cuando hago que se me repita el bucle en el do }while<br><br>con el String opcion;<br></span></span><span id="toBoxTo" style="display: block;"><span class="BlockEmailNoName"><br>System.out.print("\n\t¿Desea seguir realizando altas?(S/N)");<br>opcion=sc.nextLine();</span></span><br><span id="toBoxTo" style="display: block;"><span class="BlockEmailNoName">en el do{ while(opcion=="S"); <br><br>No se me repite cuando me dice quiere seguir realizando altas y le doy S. Que puede ser?<br><br>Saludos comunidad<br><br>public static void altas()<br> {<br> Scanner sc = new Scanner(System.in);<br> String nombre, telefono, direccion;<br> String opcion;<br> int edad;<br> try{<br> TablaBaseDatos t = new TablaBaseDatos("Agenda.txt");<br> int nR = t.dameNumeroRegistros();<br> do{<br> System.out.print("\n\tContacto nº "+(nR+1));<br> System.out.print("\n\tIntroduce el nombre");<br> nombre = sc.nextLine();<br> System.out.print("\n\tIntroduce el telefono");<br> telefono = sc.nextLine();<br> System.out.print("\n\tIntroduce la direccion: ");<br> direccion = sc.nextLine();<br> System.out.print("\n\tIntroduce la edad: ");<br> edad = sc.nextInt();<br> nR++;<br> t.escribeRegistro(nombre,telefono,direccion,edad,nR);<br> System.out.print("\n\t¿Desea seguir realizando altas?(S/N)");<br> opcion=sc.nextLine();<br> }while(opcion=="S" || opcion=="s");<br> t.cierraTabla();<br> }<br> catch(Exception e)<br> {<br> System.out.println(e);<br> }<br> <br> <br> }<br></span></span> </div></body>
</html>