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
Gemiola [76]
3 years ago
13

Debug the recursive reverseString method, which is intended to return the input String str reversed (i.e. the same characters bu

t in reverse order).
Use the runner class to test this method but do not write your own main method or your code will not be graded correctly.
public class U10_L2_Activity_One
{
public static String reverseString(String str)
{
if (str.length() < 0)
{
return str;
}
s = reverseString(str.substring(2)) + str.substring(0,1);
}
}
Runner's code (don't change):
import java.util.Scanner;
public class runner_U10_L2_Activity_One
{
public static void main(String[] args)
{
System.out.println("Enter string:");
Scanner scan = new Scanner(System.in);
String s = scan.nextLine();
System.out.println("Reversed String: " + U10_L2_Activity_One.reverseString(s));
}
}
Computers and Technology
1 answer:
Nady [450]3 years ago
7 0

Answer:

Explanation:

The following modified code correctly uses recurssion to reverse the string that was passed as a parameter to the reverseString method. A test output using the runner class can be seen in the attached image below.

import java.util.Scanner;

class U10_L2_Activity_One {

   public static String reverseString(String str) {

       if (str.isEmpty()) {

           return str;

       }

       return reverseString(str.substring(1)) + str.charAt(0);

   }

}

class runner_U10_L2_Activity_One

{

   public static void main(String[] args)

   {

       System.out.println("Enter string:");

       Scanner scan = new Scanner(System.in);

       String s = scan.nextLine();

       System.out.println("Reversed String: " + U10_L2_Activity_One.reverseString(s));

   }

}

You might be interested in
A large retail company hires several new joiners and would like to incorporate Virtual Reality (VR) into their onboarding proces
Volgvan

 The best utilize VR for this purpose is a simulated experience interacting with customers.

<h3>What is Virtual reality (VR)?</h3>

Virtual Reality (VR) is known to be a kind of computer created environment that is made up of scenes and objects that seems to be real.

It is a type of reality that makes its  user feel they are inside their surroundings. This environment is said to be seen via device known as a Virtual Reality headset or helmet.

See options below

Which approach would best utilize VR for this purpose?

an animated video that covers compliance training

a 360-degree online tour of the retail store

an application that enables online contract signing

a simulated experience interacting with customers

Learn more about Virtual Reality (VR) from

brainly.com/question/26705841

4 0
2 years ago
What kind of script is used to run code on the client
s2008m [1.1K]

Answer: JavaScript. What kind of script is used to run code on the client

4 0
2 years ago
Is used to process certificates and private/public key information?
Luda [366]
<span>SSL is used to process certificates and private/public key information. </span>SSL stands for Secure Sockets Layer. It is cryptographic protocols <span> that creates a trusted environment and </span>provides communications security over a computer network. The SSL protocol is used for establishing encrypted links between a web server and a browser.
4 0
3 years ago
Does anybody know a better app I can use instead of Brainly
melomori [17]

Answer:

Education subreddits on reddit

Explanation:

6 0
3 years ago
Read 2 more answers
What is one effect the internet has had on the library
Shkiper50 [21]

Answer:

The internet provides access to an abundance of information from home, making it easier for people to get answers much faster. This efficiency has caused libraries to receive less business and less users, therefore making their service less popular.

7 0
3 years ago
Other questions:
  • Brenda wants to finish her presentation with a summary slide . She wants three key messages to appear on each of the photo clips
    6·2 answers
  • Computer hardware had been designed to run a single operating system and a single app, leaving computers vastly underutilized. o
    15·1 answer
  • Which operating system became obsolete with the arrival of a more advanced graphical user interfaces
    6·1 answer
  • If you want the date in your document to update each time the document is opened, _____.
    9·2 answers
  • Which of the following image file formats uses lossy file compression?
    7·1 answer
  • Match the job titles to the tasks
    11·2 answers
  • High capacity circuits are limited by the least capable network link, which is typically the user connection. As such, it is imp
    11·1 answer
  • Can I ask a computer question based on engineering?
    8·1 answer
  • Explain the emerging trends in microcomputer technology in relation to size​
    11·1 answer
  • 4.7 code practice question 2 edhesive i cant figure out the code for this problem csn anyone help me?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!