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
Alex73 [517]
3 years ago
8

Write method reverseString, which takes a string str and returns a new string with the characters in str in reverse order. For e

xample, reverseString("ABCDE") should return "EDCBA".
Complete the reverseString method below by assigning the reversed string to result.

/** Takes a string str and returns a new string

* with the characters reversed.

*/

public static String reverseString(String str)

{

String result = "";

return result;

}
Computers and Technology
1 answer:
son4ous [18]3 years ago
3 0

Answer:

The method written in Java is as follows:

public static String reverseString(String str){

    String result = "";

    int lentt = str.length();

    char[] strArray = str.toCharArray();

       for (int i = lentt - 1; i >= 0; i--)

           result+=strArray[i];

    return result;

}

Explanation:

This defines the method

public static String reverseString(String str){

This initializes the result of the reversed string to an empty string

    String result = "";

This calculates the length of the string

    int lentt = str.length();

This converts the string to a char array

    char[] strArray = str.toCharArray();

This iterates through the char array

       for (int i = lentt - 1; i >= 0; i--)

This gets the reversed string

           result+=strArray[i];

This returns the reversed string            

    return result;

}

<em>See attachment for full program that includes the main method</em>

Download txt
You might be interested in
What size font is appropriate for most on-screen presentation slides?
Natali [406]
It's heading 2 or 3, because heading 1 is considerd as too big for slide presentations.
6 0
3 years ago
HELP ME!!!!!!!!!!!!
slavikrds [6]

Answer: c

Explanation: because that’s the group it’s under

6 0
4 years ago
The blank contains the computer's brain the central processing unit CPU
Ipatiy [6.2K]

The central processing unit (CPU), also called a processor, is located inside the computer case on the motherboard. Hope it helps (:

6 0
3 years ago
Importance of spread sheets​
Tema [17]

Answer:

It’s not that important but you can use it to help organize and grow your business.

Explanation:

3 0
3 years ago
DISEÑAR EL SIGUIENTE FORMULARIO: Y CALCULAR EN PHP: ¿cuánto pagaría un cliente, si elige un plan de pagos de acuerdo a los sigui
Karolina [17]
Sorry don’t get your language
3 0
3 years ago
Other questions:
  • Create a project for a sandwich shop. The project, named SalsSandwiches, allows a user to use a ListBox to choose a type of sand
    5·1 answer
  • How can touch typing quickly but accurately improve your earnings (the money you can make)
    15·2 answers
  • Write a program that reads in two integers typed on the keyboard and outputs their sum, difference, and product.
    12·1 answer
  • When creating a new user in linux, after entering the name, the username box:?
    9·1 answer
  • A construction company has an online system that tracks all of the status and progress of their projects. The system is hosted i
    10·1 answer
  • Write a program whose input is two integers and whose output is the two integers swapped. Ex: If the input is: 3 8 then the outp
    12·1 answer
  • One of the implications of price elasticity of technology products is that:
    11·1 answer
  • 11.5 Code Practice edhesive
    10·2 answers
  • Write a program to have the computer guess at a number between 1 and 20. This program has you, the user choose a number between
    9·1 answer
  • Jared is a corporate trainer who creates presentations to deliver at workshops. When creating these
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!