Answered step by step
Verified Expert Solution
Link Copied!

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Genomes Browsers And Databases Data Mining Tools For Integrated Genomic Databases

Authors: Peter Schattner

1st Edition

0521711320, 978-0521711326

More Books

Students also viewed these Databases questions

Question

What is database?

Answered: 1 week ago

Question

What are Mergers ?

Answered: 1 week ago

Question

Prepare an electronic rsum.

Answered: 1 week ago

Question

Strengthen your personal presence.

Answered: 1 week ago

Question

Identify the steps to follow in preparing an oral presentation.

Answered: 1 week ago