I'm a begginner in Java
and I have a question about convert String
to a Class
Type (?).
My main class have this:
Scanner scanner = new Scanner(System.in);
System.out.println("Inserir 1o nome:");
String firstname = scanner.next();
System.out.println("Inserir apelido:");
String lastname = scanner.next();
System.out.println("Inserir género:");
String gender = scanner.next();
System.out.println("Inserir tipo de funcionário (A, B ou C):");
String type = scanner.next();
But I have to convert last String
to an enum type:
public enum EmployeeType {
A,
B,
C
}
Any hint?
You can do :