I need to create a random string of letters, but have never used the random class before.
here is the spec: Create a small program that will ask the user to enter their name. Store the name in a string Print the name Ask the user to change their last name Manipulate the string to the new last name. Print the new name. Create an infinite loop that will change the string variable randomly. See if your program will crash.
so far I have this
import java.util.Scanner;
import java.util.Random;
public class StringNames {
public static void main(String[] args) {
System.out.println("Please enter a name");
Scanner myInput = new Scanner(System.in);
String firstName = new String();
firstName = myInput.next();
String lastName = new String();
lastName = myInput.next();
System.out.println(firstName + " " + lastName);
System.out.println("Please change your last name");
lastName = myInput.next();
System.out.println(firstName + " " + lastName);
for (;;) {
}
}
}
How can I create a random string of letters to change the last name to in the infinite loop? I am unsure how long the string has to be. The simpler the code the better. I am slow.
Thank you for your guidance