Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Spring Framework | Web Services | BioInformatics | Java Server Faces | Jboss 3.0 tutorial | Hibernate 3.0 | XML

Tutorial Categories: Ajax | Articles | JSP | Bioinformatics | Database | Free Books | Hibernate | J2EE | J2ME | Java | JavaScript | JDBC | JMS | Linux | MS Technology | PHP | RMI | Web-Services | Servlets | Struts | UML


 

Java Tutorials


 

 

Struts Tutorials

Struts Resources

Visit Forum! Post Questions!
Jobs At RoseIndia.net!

Java Beginners StringReverseExample

User Comments
Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl
  Blink   Furl   Simpy   Y! MyWeb 

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 

Current Comments

21 comments so far (post your own) View All Comments Latest 10 Comments:

Why We need Different kinds of inputstrem.the following Stream is enough for all type of data.BufferedReader obj1=new BufferedReader(new InputStreamReader(System.in));
Then why we need all kinds of StreamMethods....pls clarify my doubts...,

Posted by Baskaranb on Tuesday, 10.5.10 @ 20:26pm | #100069

difference between portability and plateform independency?

Posted by vikas verma on Thursday, 09.9.10 @ 23:14pm | #99488

class Str
{
public static void main(String args[]) throws Exception
{
String s1="naren";
int n=s1.length();
for(int i=n-1;i>=0;i--)
{
System.out.print(""+s1.charAt(i));
}
}
}

Posted by naren on Friday, 08.27.10 @ 18:19pm | #99218

How to print a statement reverse by word(e.g My Name is Khan prints:"Khan is Name My")

Posted by Kalpant on Thursday, 07.29.10 @ 14:38pm | #98510

its good

Posted by sandhuru on Tuesday, 07.13.10 @ 18:24pm | #98162

very nice program for string reverse.i dont know how to get character from keyboard tell me

Posted by john peter on Wednesday, 07.7.10 @ 16:40pm | #98019

any one plz solve this question

WAP to accept a string (containg three words) and display the same in reverse order.

Input: computer is fun
Output: fun is computer

Posted by sksinha on Friday, 07.2.10 @ 19:24pm | #97913

This will throw ArrayIndexOutOfBoundsException

Posted by Hari on Friday, 06.18.10 @ 10:30am | #97655

Dear Sir,

I want to know the aprogramming fot this quest:-


Write an applets a string as input and prints it in reverse order.

would be very greateful if you could sir.

Regards
kalyani

Posted by kalyani on Saturday, 05.1.10 @ 14:38pm | #96742

Modify the program by reversing the third name entered into the array.



import javax.swing.*;

public class TMA_Q3{

public static void main(String[]args){

String Name1,Name2,Name3,Name4,Name5,outputStr;


Name1 = JOptionPane.showInputDialog(null,"Enter First Name :","TMA3_Q3",JOptionPane.QUESTION_MESSAGE);
Name2 = JOptionPane.showInputDialog(null,"Enter Second Name :","TMA3_Q3",JOptionPane.QUESTION_MESSAGE);
Name3 = JOptionPane.showInputDialog(null,"Enter Third Name :","TMA3_Q3",JOptionPane.QUESTION_MESSAGE);

String[]Name = {Name1,Name2,Name3};


outputStr = " Thirdly Entered Name is : " + Name[2] + "\n" ;

JOptionPane.showMessageDialog(null, outputStr ,"Thirdly Entered Name ", JOptionPane.INFORMATION_MESSAGE);

System.out.println("Thirdly Entered Name is: " + Name[3]);

String [] thirdname = {Name3};

thirdname[0]= thirdname[0].substring(0,8);

System.out.println("Length of Third Name: " + thirdname.length);

System.out.println("\n " + thirdname[0]);


for(int i=8 ; i>=0; i--)

{System.out.print(" " + thirdname[i]);}


}
}

}

Posted by jay on Sunday, 04.11.10 @ 14:53pm | #96292

public class ReverseSentence {
public static void main(String[] args) {
String[] temp;
temp = args[0].split(" ");
System.out.println("Array length : " + temp.length);
for (int i = temp.length; i > 0; i--)
System.out.print(temp[i-1] + " " );
System.out.println("");
}
}

Posted by Ashok on Wednesday, 12.9.09 @ 11:19am | #93204

this is a different way you can do it

import java.util.Scanner;
public class Introduction_to_Arrays {
public static void main(String[] args){
Scanner input = new Scanner(System.in);
String txt = input.nextLine();
String output = "";
int r = 0;
while(r < txt.length()){
for (int i = 0; i < txt.length();i++){
output+=(txt.substring(txt.length() - 1-i,txt.length()-i ));
r++;
}
}
System.out.println(output);

}
}

Posted by rino on Friday, 08.14.09 @ 02:20am | #90013

string program using java

Posted by shoba on Thursday, 07.16.09 @ 18:47pm | #89389

Hi,

This is very grate site craeted for learners to learn step by step.

This is laso useful for self-learning.

Thank you!
Regards,
Suganya.R

Posted by Suganya.R on Tuesday, 06.16.09 @ 17:18pm | #88545

how do i reverse this array,

1,2,3,4,5,6,7

reverse the sequence of the numbers, without creating any additional array.

Posted by Jango on Saturday, 05.2.09 @ 09:36am | #87329

Your website greatly help me in solving my assignment. thank you very much.


p.s

try to post correct program in java.please..

Posted by mary on Friday, 03.20.09 @ 02:37am | #86035

I need to know more about Reverse methods . Can you please show how I could do it better

Posted by Nombulelo on Wednesday, 03.11.09 @ 01:41am | #85723

Been running yout reverse String program and I am trying to do a reverse on a Reverse.java file. Prints file forward but bit confused on how to reverse it. haven't found any samples out there

import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.InputStreamReader;
public class Reverse
{
public static void main(String[] args)
{
try{
// Open the file that is the first
// command line parameter
FileInputStream fstream = new
FileInputStream("C:\\Users\\Phillip\\workspace\\Part-1 Lectures\\src\\Reverse.java");
// Get the object of DataInputStream
DataInputStream in = new DataInputStream(fstream);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String strLine;
//Read File Line By Line
while ((strLine = br.readLine()) != null) {
// Print the content on the console
System.out.println (strLine);

//System.out.println("File Reversed is" +strLine.reverse);

}
//Close the input stream
in.close();
}catch (Exception e){//Catch exception if any
System.err.println("Error: " + e.getMessage());
}
}
}

Posted by Phillip on Saturday, 02.21.09 @ 18:00pm | #85080

this site is very useful to me to know many things

Posted by rami on Thursday, 02.5.09 @ 05:01am | #84521

Can you please show me some advanced applet programming ? I would be very greateful if you could sir.
thanking you,
yours faithfully,
Pema

Posted by Pema on Friday, 05.16.08 @ 14:47pm | #60148

Regarding your String Reverse example, how to reverse the order of each word of the String after reverse its order from the original. So that the result will be: "you are how hi".

To continue on your example what are the commands will be used??

Posted by Peg on Wednesday, 04.23.08 @ 04:39am | #57636

Ask programming questions?

 

 

Back to Tutorial

 

  JDO Tutorials
  EAI Articles
  Struts Tutorials
  Java Tutorials
  Java Certification

Tell A Friend
Your Friend Name

 

 
Browse all Java Tutorials
Java JSP Struts Servlets Hibernate XML
Ajax JDBC EJB MySQL JavaScript JSF
Maven2 Tutorial JEE5 Tutorial Java Threading Tutorial Photoshop Tutorials Linux Technology
Technology Revolutions Eclipse Spring Tutorial Bioinformatics Tutorials Tools SQL
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright 2007. All rights reserved.