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
mestny [16]
3 years ago
10

Write a method that accepts a String object as an argument and displays its contents backward. For instance, if the string argum

ent is "gravity" the method should display "ytivarg". Demonstrate the method in a program that asks the user to input a string and then prints out the result of passing the string into the method.
Computers and Technology
1 answer:
Nata [24]3 years ago
6 0

Answer:

// importing the necessary libraries

import java.util.Scanner;

public class BackwardString {

public static void main(String[] args) {

String input;

// Scanner object to read string from user input

Scanner scanner = new Scanner(System.in);

System.out.print("Enter String here : ");

input=scanner.next();

// calling backward method to reverse passed string

backward(input);

// closing Scanner object

scanner.close();

}

// Method to Reverse the input string

private static void backward(String source) {

int i, len = source.length();

StringBuilder dest = new StringBuilder(len);

for (i = (len - 1); i >= 0; i--){

dest.append(source.charAt(i));

}

System.out.println("Reversed String : "+dest);

}

}

Explanation:

// importing the necessary libraries

import java.util.Scanner;

public class BackwardString {

public static void main(String[] args) {

String input;

// Scanner object to read string from user input

Scanner scanner = new Scanner(System.in);

System.out.print("Enter String here : ");

input=scanner.next();

// calling backward method to reverse passed string

backward(input);

// closing Scanner object

scanner.close();

}

// Method to Reverse the input string

private static void backward(String source) {

int i, len = source.length();

StringBuilder dest = new StringBuilder(len);

for (i = (len - 1); i >= 0; i--){

dest.append(source.charAt(i));

}

System.out.println("Reversed String : "+dest);

}

}

The program above accepts a String object as an argument and displays its contents backward.

It reverses the any string inputed while producing the output.

You might be interested in
Units for measuring computer memory
lyudmila [28]

A kilobyte (KB) is 1,024 bytes, not one thousand bytes as might be expected, because computers use binary (base two) math, instead of a decimal (base ten) system. Computer storage and memory is often measured in megabytes (MB) and gigabytes (GB). A medium-sized novel contains about 1 MB of information.

6 0
4 years ago
?trophic levelNYIGVU.;/IO9YK7,'0;
grin007 [14]

please add more information, about your answer {history restored}

go to brainly.com for [HELP]

7 0
3 years ago
Yari is having trouble determining the appropriate combination of f-stop and shutter speed for a still image he is taking. What
lapo4ka [179]
C it’s tripod that can help hair
5 0
3 years ago
Google Pay utilizes smartphones with near field communication technology, such as _____, to allow shoppers to swipe their phone
gregori [183]

Answer:

RFID (radio frequency identification)

Explanation:

Radio Frequency Identification makes use of electromagnetic fields to automatically identify and track tags attached to objects. The tags holds electronically stored information. A RFID tag can be passive, that is, only tracks tags that are very close to it and needs no power, or Active, that is, it needs small battery power and can track tags close to 100 meter way. It does not need a line of sight to track, which makes it better to use in phones and other hand held devices.

With this technology, a shopper can automatically pay for items at checkout points.

4 0
3 years ago
PLEASE HELP AND HURRY!!!
Ber [7]

Answer:

Shape Styles

Hope this helps :)

Mark me brainiest

Explanation:

8 0
3 years ago
Read 2 more answers
Other questions:
  • Which of the following was one of the first internet search engines? A. archie B. google C. Yahoo D.ask
    7·1 answer
  • What frequency band is used by bluetooth, 802.11b, and 802.11g?
    12·1 answer
  • Which of the following function headings arevalid? If they are invalid, explain why.
    12·1 answer
  • Barbara has three computers connected to the same network in her home. What
    15·1 answer
  • Which component is a part of the CPU of a computer
    12·2 answers
  • Can you please help me
    9·1 answer
  • Select the phrases that apply to Java classes or methods.
    8·1 answer
  • How will understanding IT help me achieve my goals in life?
    14·1 answer
  • How to transfer word 2019 from one computer to another
    12·1 answer
  • A(n) __________ is a common list operation used in programming. Its purpose is to iterate through a list of items, one item at a
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!