how to reverse a string without changing its place

how to reverse a string without changing its place

how to reverse a string without changing its place

View Answers

January 25, 2011 at 10:49 AM

Hi Friend,

Another way of reversing string:

import java.util.*;
public class ReverseString{

    public static void main(String[]args){
    Scanner input=new Scanner(System.in);
    System.out.print("Enter String: ");
    String st=input.nextLine();
    String str[]=st.split("");
    String reversedSt="";
    for(int i=str.length-1;i>=0;i--){
    reversedSt+=str[i];
    }
    System.out.println("Reversed String is: "+reversedSt);
    }
}

Thanks


May 12, 2011 at 8:01 PM

public class reverse {

public static void main(String args[])
{
    StringBuffer s=new StringBuffer("Java is interesting");
    System.out.println("Before reversing the string :"+s);
    s=s.reverse();
    System.out.println("After Reverse string is :"+s);




}

}









Related Tutorials/Questions & Answers:
how to reverse a string without changing its place
how to reverse a string without changing its place  how to reverse a string without changing its place   Hi Friend, Another way of reversing string: import java.util.*; public class ReverseString{ public static
print reverse string without api
print reverse string without api  accept a string and print reverse without using api
Advertisements
reverse string
reverse string  how to reverse a string without changing its place...=input.nextLine(); String reverse = new StringBuffer(str).reverse().toString...{ public static void main(String[]args){ Scanner input=new Scanner
How to declare a Combobox without using a string in its declaration?
How to declare a Combobox without using a string in its declaration?  What i mean to ask is how can i declare a combobox first and initialise the values later? For example JComboBox x= new JComboBox(); ... String s={"Alpha
Java reverse string without using inbuilt functions
Java reverse string without using inbuilt functions In this tutorial, you will learn how to reverse string without using any inbuilt functions. Here, we have created a method to reverse the string and returns a new string with reverse
String Reverse In Java Example
String Reverse In Java Example In this tutorial we will read about reversing a String in Java. Here we will see how a String can be represented in its... is being given which will demonstrate you about how to reverse a String using
String reverse in java
String reverse in java In this section we are going to discuss about how... in java but in most interview they will ask to reverse a string without... as by loop.  Now here is the example how to reverse a string in java
How to save data to excel with a 2.1 work sheet format without changing it?
How to save data to excel with a 2.1 work sheet format without changing...(String[] args) { new JTableToExcel(); } public JTableToExcel(){ JFrame frame = new JFrame("Getting Cell Values in JTable"); JPanel panel = new JPanel(); String
Reverse string in BlueJ
Reverse string in BlueJ  wap that user enter a string and one word. so i want that program search word in string entered by user if word exist in string than reverse only that word and give output. e.g This is a flower (string
string reverse order
string reverse order  Hi I have string s= " kalins naik" then how can i print string s=" naik kalins" Thanks kalins naik   import java.util.*; public class ReverseWords{ public static void main(String[] args
String reverse program
String reverse program  write a java program for reverse string? if the string is "Hi welcome to hyderabad" the reverse string is "hyderabad... for help. You can split the String into String array using split method of String
Java reverse words in a string using only loops
Java reverse words in a string using only loops In this tutorial, you will learn how to reverse words in a string without using any inbuilt methods like...;=c.length;i++) { if(i==c.length) { reverse(c,word_start_index,i-1); } else
String Reverse in Java
StringReverseExample "hi how are you." String before reverse: hi how... String Reverse in Java       In this example we are going to reverse a given string
Reverse String using Stack
Reverse String using Stack You all are aware of Stack, a data structure... in the reverse order from that in which they are added. The push operation is responsible for adding the element and pop for removing. Here we are going to reverse
A Program To Reverse Words In String in Java
A Program To Reverse Words In String in Java  A Program To Reverse Words In String in Java for example: Input:- Computer Software Output :- Software Computer without using split() , StringTokenizer function or any extra
C String Reverse
C String Reverse       In this section, you will study how to reverse a string. You can see in the given example, a recursive function reverse(int i) is created. Inside
A Program To Reverse Words In String in Java .
A Program To Reverse Words In String in Java .  A Program To Reverse Words In String in Java :- For Example :- Input:- Computer Software Output :- Software Computer
A Program To Reverse Words In String in Java .
A Program To Reverse Words In String in Java .  A Program To Reverse Words In String in Java :- For Example :- Input:- Computer Software Output :- Software Computer
A Program To Reverse Words In String in Java .
A Program To Reverse Words In String in Java .  A Program To Reverse Words In String in Java :- For Example :- Input:- Computer Software Output :- Software Computer
A Program To Reverse Words In String in Java .
A Program To Reverse Words In String in Java .  A Program To Reverse Words In String in Java :- For Example :- Input:- Computer Software Output :- Software Computer
A Program To Reverse Words In String in Java .
A Program To Reverse Words In String in Java .  A Program To Reverse Words In String in Java :- For Example :- Input:- Computer Software Output :- Software Computer
how to convert string to char array in java without using tochararray
how to convert string to char array in java without using tochararray  Hi, I want to convert the String object in java without the toChararray() function. how to convert string to char array in java without using
Reverse word of string in alphabetical order
Reverse word of string in alphabetical order  wap a program that reverse word of string in alphabetical order. e.g. input by user The purpose of education is to replace an empty mind with an open one output
String Reverse Using StringUtils
The delimited Reverse string: YOU? R How Hi, Download this example.ADS... String Reverse Using StringUtils       In this example we are going to reverse a given string using
Getting the string in reverse
Getting the string in reverse  i am giving the string=" i am sachin".for this output is "sachin am i".please give me the code?   Hi Friend, Visit Here Thanks
Getting the string in reverse
Getting the string in reverse  i am giving the string=" i am sachin... static void main(String[] args) { Scanner input=new Scanner(System.in); System.out.print("Enter String: "); String st=input.nextLine
Reverse String Program in Java
reverse string without using inbuilt functions Java : String Compare...Reverse String Program in Java We are going to describe about reverse...(String args[]) { String string, reverse = ""; Scanner
how to start intergrated webcam of a laptop without calling its exe file using java only - Java Beginners
how to start intergrated webcam of a laptop without calling its exe file using java only  how to open integrated webcam of a laptop without calling its exe file using java only?.simply what i am asking is that is there any method
JavaScript reverse text string
JavaScript reverse text string...; In this section, we are going to reverse the text string using JavaScript... entering the text, you will get the reverse string in the same text box. Here
Java Reverse words of the String
Reverse words of the String Java Programming In this section, we are going to reverse the words of the string. For this, we have allowed the user to enter the string. Then we have converted the string into tokens using StringTokenizer
Java Reverse String Pattern
Java Reverse String Pattern In this section, we have displayed a string in reverse pattern. For this,we have specified a string which is first converted... StringBuffer(st).reverse().toString() and gain convert this string into character
Java repeat string without using loops
Java repeat string without using loops In this section, you will learn how to repeat string without using for loops. The given example accepts the number of times and iterates the string to the number of times set by the user without
Breaking a string into words without using StringTokenizer
Breaking a string into words without using StringTokenizer  how can we Break a string into words without using StringTokenizer ??   The given code convert the string into words. import java.util.*; class StringExample
reverse words in a string(words seperated byone or more spaces)
reverse words in a string(words seperated byone or more spaces)  reverse words in a string(words separated by one or more spaces
Reverse String
Reverse String      ... it in its backward direction on the console. Description of program:ADS... it in a string type array passed into the main method. Then we are taking
String length without using length() method in java
String length without using length() method in java  How to count length of string without using length() method in java?   Here is Example... the number of character into the given string without using the length() method
Reverse
Reverse  How to reverse two digits in javaprogramming
Reverse
Reverse  How to reverse two digits in javaprogramming
Out of bounce exception in the string reverse program - Java Beginners
Out of bounce exception in the string reverse program  In the given... void main(String[] args) { String string=args[0]; String reverse = new StringBuffer(string). reverse().toString(); System.out.println
reverse the charstring
reverse the charstring  how to reverse any character of the string
reverse
reverse  program to read a string and print the reverse string  ...*; public class ReverseString{ public static void main(String[]args){ Scanner input=new Scanner(System.in); System.out.print("Enter String
How to Changing Toolbar Color using iPhone Application ?
How to Changing Toolbar Color using iPhone Application ?  Hi, i have developing a small application to changing the toolbar color in iphone. But i have facing the problem that color is not changing. Can somebody suggest me
How to design a changing color of the chameleon, changing color of the chameleon, color of the chameleon
How to design a changing color of the chameleon       Have you seen the chameleon to changing the color, you can see now by this example. Let's see how the chameleon
How to display string or character
How to display string or character  how to print character or a word without using array concept
I retrieve a String or other object type without creating a new object each time.
I retrieve a String or other object type without creating a new object each time.  How can I retrieve a String or other object type without creating a new object each time
How to use place hoder in IE(version : 8)
How to use place hoder in IE(version : 8)  how to use placeholder for input field(type=text) and password field (type= password) in IE
Read a string and reverse it and then print in alphabetical order.
Read a string and reverse it and then print in alphabetical order... given below takes string value from user and reverse that string by using String reverse(String str) method and set in alphabetical order by String
Java reverse number
Java reverse number In this tutorial, you will learn how to reverse a number...(/) and remainder operator(%) to reverse the number. The division operator returns... ReverseNumber{ public static void main(String [] args){ Scanner input=new Scanner
How to display jfreechart at specified place in jsp
How to display jfreechart at specified place in jsp  I have a jsp page where i need to display the chart at specified position .But With the following codes chart is getting loaded as png image and all other css design elements
without ;
without ;  can u give me an example of a program without

Ads