answersLogoWhite

0

//code for reverse string

class ReverseString

{

public static void main(String arg[])

{

StringBuffer s=new StringBuffer("abcdef");

System.out.println("Before reversing :"+s);

s.reverse();

System.out.println("after reversing.."+s);

}

}

User Avatar

Wiki User

13y ago

What else can I help you with?

Continue Learning about Engineering

How do you convert a number that consist of alphabet and number in reverse order?

To reverse a number, first convert the number to a string, then reverse the string. Given your number consists of alphanumeric characters, the number must already be a string so simply reverse the string: #include<string> using std::string; string reverse (const string& s) { string str {}; for (auto c : s) str.insert (str.begin(), c); return str; } int main () { std::cout << "Enter a number: "; string s {}; std::cin >> s; std::cout << "The number in reverse is: " << reverse (s); }


How do you get value of a string in reverse order in c?

Assume C#, not C: Traditional way: public string Reverse(string s) { if (string.IsNullOrEmpty(s)) return s; // "" or null char[] characters = s.ToCharArray(); Array.Reverse(characters); return new string(characters); } or as an extension method: public static string Reverse(this string s) { if (s == "") return ""; char[] characters = s.ToCharArray(); Array.Reverse(characters); return new string(characters); } The differences of the 2 methods above is on the caller (how to use Reverse()), and they may co-exist: For example: string test = "abc"; string result1 = Reverse(test); // traditional way string result2 = test.Reverse(); // call the extension


A program of c plus plus to accept the string and display the alternate characters in reverse order using pointer?

The following program prints every second character of the input in reverse order. #include<iostream> #include<sstream> int main() { std::cout << "Input:\t"; std::string input = ""; std::getline (std::cin, input); if (input.size()) { std::cout << "Output:\t"; unsigned index = input.size() / 2 * 2; do { index -= 2; std::cout << input[index]; } while (index); std::cout << std::endl; } }


How would you write a program that takes a string of characters and reverses them in the C programming language?

void main() {char a[30] = "India"; //Let the string be stored in a[30]; char b[30]; //declaring another string for(i=0;i<strlen(a);i++) {b[strlen(a)-1 - i]=a[i];} //Now reverse string is stored in b; //to print it cout<<b; getch(); }


How do you program a reverse auto loan calculator in JAVA?

In order to program a reverse auto loan calculator in JAVA, you are going to need a lot of experience with JAVA. There are online tutorials that can help you set up with fundamentals of JAVA so that you will be able to create almost any basic program you want.

Related Questions

How do you convert a number that consist of alphabet and number in reverse order?

To reverse a number, first convert the number to a string, then reverse the string. Given your number consists of alphanumeric characters, the number must already be a string so simply reverse the string: #include<string> using std::string; string reverse (const string& s) { string str {}; for (auto c : s) str.insert (str.begin(), c); return str; } int main () { std::cout << "Enter a number: "; string s {}; std::cin >> s; std::cout << "The number in reverse is: " << reverse (s); }


How do you get value of a string in reverse order in c?

Assume C#, not C: Traditional way: public string Reverse(string s) { if (string.IsNullOrEmpty(s)) return s; // "" or null char[] characters = s.ToCharArray(); Array.Reverse(characters); return new string(characters); } or as an extension method: public static string Reverse(this string s) { if (s == "") return ""; char[] characters = s.ToCharArray(); Array.Reverse(characters); return new string(characters); } The differences of the 2 methods above is on the caller (how to use Reverse()), and they may co-exist: For example: string test = "abc"; string result1 = Reverse(test); // traditional way string result2 = test.Reverse(); // call the extension


A program of c plus plus to accept the string and display the alternate characters in reverse order using pointer?

The following program prints every second character of the input in reverse order. #include<iostream> #include<sstream> int main() { std::cout << "Input:\t"; std::string input = ""; std::getline (std::cin, input); if (input.size()) { std::cout << "Output:\t"; unsigned index = input.size() / 2 * 2; do { index -= 2; std::cout << input[index]; } while (index); std::cout << std::endl; } }


How can you generate a palindrome from a given number?

You write the number and then follow it with the digits in reverse order.


How would you write a program that takes a string of characters and reverses them in the C programming language?

void main() {char a[30] = "India"; //Let the string be stored in a[30]; char b[30]; //declaring another string for(i=0;i<strlen(a);i++) {b[strlen(a)-1 - i]=a[i];} //Now reverse string is stored in b; //to print it cout<<b; getch(); }


How do you write a sentence using taut?

" A guitar string needs to be quite taut in order for it to produce an even tone."


How do you program a reverse auto loan calculator in JAVA?

In order to program a reverse auto loan calculator in JAVA, you are going to need a lot of experience with JAVA. There are online tutorials that can help you set up with fundamentals of JAVA so that you will be able to create almost any basic program you want.


When a middle school student is able to demonstrate the he or she is able to hear a string of digits 1 2 3 4 etc and then repeat the string in reverse order the child is indicating that he or she is?

I have no clue what you're asking, could you dumb it down for me.


What is a silly way to remember the planets backwards?

Write the names in order on a piece of paper, then turn it upside down and you can read the names in reverse order.


Write a program to sort elements of an array in ascending order?

import java.util.Arrays; public class arraysort { public static void main(String[] a) { int array[] = { 2, 5, -2, 6, -3 }; Arrays.sort(array); for (int i : array) { System.out.println(i); } } }


Write a program WAP to print a given integer in the reverse order?

int n; // the number you want to reverse int rev_n = 0; while (n > 0) { // shift rev_n digits left rev_n *= 10; // put rightmost digit of n onto right of rev_n rev_n += n % 10; // remove rightmost digit of n n /= 10; }


How can a stack determine if a string is a palindrome?

foreach char in string push on to stack create new string foreach char in string pop off and add to end of new string if new string equals old string palindrome else not palindrome //when you pop off the stack, the characters come off in reverse order, thus you have reversed the original string