public class MainTest {
public static void main(String args[]) {
String str;
int len;
Scanner scan = new Scanner(System.in);
System.out.print("Enter Your Name : ");
str = scan.nextLine();
len = str.length();
System.out.print("Length of Entered String is " + len);
}
}
After running i put the name "aaa", press enter and the "aaa" turn into "asa" and the part of the length of strings plays normal
package Com.test; import java.util.Scanner;
public class MainTest { public static void main(String args[]) { String str; int len; Scanner scan = new Scanner(System.in); System.out.print("Enter Your Name : "); str = scan.nextLine(); len = str.length(); System.out.print("Length of Entered String is " + len); } }
After running i put the name "aaa", press enter and the "aaa" turn into "asa" and the part of the length of strings plays normal