1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
disa [49]
3 years ago
7

Write a recursive method called repeat that accepts a string s and an integer n as parameters and that returns s concatenated to

gether n times. For example, repeat("hello", 3) returns "hellohellohello", and repeat("ok", 1) returns "ok", and repeat("bye", 0) returns "". String concatenation is an expensive operation, so for an added challenge try to solve this problem while performing fewer than n concatenations.
Computers and Technology
1 answer:
svp [43]3 years ago
6 0

Answer:

public static String repeat(String text, int repeatCount) {

   if(repeatCount < 0) {

       throw new IllegalArgumentException("repeat count should be either 0 or a positive value");

   }

   if(repeatCount == 0) {

       return "";

   } else {

       return text + repeat(text, repeatCount-1);

   }

}

Explanation:

Here repeatCount is an int value.

at first we will check if repeatCount is non negative number and if it is code will throw exception.

If the value is 0 then we will return ""

If the value is >0 then recursive function is called again untill the repeatCount value is 0.

You might be interested in
Preesure is drived quantity? why​
Marrrta [24]

Answer:

Basically, anything quantity that is not defined as one of the 7 base quantities is a derived quantity by definition. Pressure is not one of the 7 base quantities. Hence it is a derived quantity.

6 0
3 years ago
Read 2 more answers
Dedicated server hosting and dedicated web dedicated is the same ??????
andrezito [222]

The correct answer is; False.

Further Explanation:

Dedicated server hosting and a dedicated shared hosting is two different things. When a person is using dedicated server hosting they are using a server that only hosts their website. When a person is using a dedicated shared host they are actually sharing the site with others. When using the shared server they must use only an allocated amount of space and bandwidth.

The costs of these services will vary depending on which you use. Shared servers will pay less for the website since they share the costs with the other site owners. While, a dedicated server will cost more since there is no one to share the cost with.

Learn more about server hosting at brainly.com/question/8429135

#LearnwithBrainly

3 0
3 years ago
RAM IS often referred
miss Akunina [59]
3

thank me later :))))))))
7 0
3 years ago
The user cannot use a computer system without.................... software<br><br>​
zheka24 [161]

Answer:

the user cannot use a computer system without hardware and software

4 0
3 years ago
Read 2 more answers
Why is graphics important in multimedia application <br>​
erastova [34]
Graphics are important in multimedia application this is because humans are visually oriented etc.
5 0
3 years ago
Other questions:
  • 50+ POINTS AND BRAIN IF CORRECT Chris is working with other employees on a worksheet. The other employees have made comments, bu
    8·1 answer
  • Suppose we eliminate tcp and instead rely exclusively on udp as our only transport layer protocol. ⢠how does this impact opera
    15·1 answer
  • What do you call the process of translating statements written by a developer? What is the result of this process?
    6·1 answer
  • What does TIA stand for?
    7·2 answers
  • What is the post condition of an expression or variable
    11·1 answer
  • Which data type or collection of data types can SOQL statements populate or evaluate to?
    9·1 answer
  • The rule of thumb that predicts that the number of transistors on a cpu will double every two years is called ________ law.
    7·1 answer
  • 1. Which of the following statements are true about routers and routing on the Internet. Choose two answers. A. Protocols ensure
    9·2 answers
  • KAPWING Video Editing Software allows you to use existing You Tube Videos in your design.
    8·1 answer
  • a company recently implemented a secure sockets layer/transport layer security (ssl/tls) version that supports secure hashing al
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!