Create a method print a string If type is not string then throw exceptionand retry 3 times
import java.util.Scanner; public class MyClass { public static void main(String args[]) { Scanner myObj = new Scanner(System.in); System.out.println("Enter username"); String userName = myObj.nextLine(); System.out.println("Username is: " + userName); } }