Inside case 1, 3 and 4 in the switch block you are setting up username with an if condition. If the condition is not true, username remains null, which might be causing the NullPointerException on username.length() in the if condition after switch block. Add else to these 3 cases and try
1 Like