How do I read strings in java within a while or do-while loop? without error and does not read
Code:
package listas;
import static java.lang.System.exit;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Listas {
//declaração de Variáveis
static List lista = new ArrayList();
static Scanner ler = new Scanner (System.in);
public static void main(String[] args) {
while (true) {
System.out.println("0-Sair");
System.out.println("1-Cadastrar");
System.out.println("2-Listar");
System.out.println("3-Remover");
char op = (char) ler.nextByte();
switch (op) {
case 0 : exit(0);break;
case 1 : cadastrar(); break;
case 2 : break;
case 3 : break;
default : {
System.out.println("Opção Inválida!");
break;
}
}
}
}
public static void cadastrar () {
System.out.print("Digite: ");
String str = new String ();
str = ler.nextLine();
}
}