Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started