Question: Java code about writing two methods: public static String randomStringone(int length) public static String randomStringtwo(int length) This method should return a String of random lowercase

Java code about writing two methods: public static String randomStringone(int length)
public static String randomStringtwo(int length)

This method should return a String of random lowercase letters with the given length by using for loops. To generate a random lowercase letter, use a local Random variable and the method nextInt() to generate a number between 97 and 122, then cast the result to a char. The method nextInt() can be found here: https://www.geeksforgeeks.org/java-util-random-nextint-java/

  • In randomStringone(), you should use String concatenation like exampleString = exampleString + exampleChar;
  • In randomStringtwo(), use the methods provided by the StringBuilder class to build your String. You will create an instance of a StringBuilder and use it to manipulate the string in progress. You need to:
    • Append chars to a StringBuilder
    • Get the String from the StringBuilder (information about StringBuilder: https://docs.oracle.com/javase/10/docs/api/java/lang/StringBuilder.html)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!