String Reverse in Java...!

Answer Posted / shadow

//command line argument as string

public class StringReverse
{
public static void main(String[] args)
{
String string=args[0];
String reverse = new StringBuffer(string).reverse
().toString();


System.out.println("\nString before reverse:"+string);
System.out.println("String after reverse:"+reverse);
}
}


output:
C:\java\jdk>javac StringReverse.java
C:\java\jdk>java StringReverse "SHADOW"
String before reverse:SHADOW
String after reverse:WODAHS

Is This Answer Correct ?    8 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How do you include a string in java?

751


What are different types of control structures?

717


Why there are some null interface in java? What does it mean?

867


How many types of assembly languages are there?

729


What is a Null object?

1200


Tell me about your ability to work under pressure

1952


How do you remove spaces in java?

753


Difference between vector and arraylist.

781


Convert a BST into a DLL and DLL to BST in place.

872


What is main difference between variable and constant?

778


What is the set interface in java programming?

839


Why string is immutable or final in java

842


What is gc()?

750


What is difference between length and length() method in java ?

767


What is sortedmap in java?

772