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

Give us a program to check for parenthesis matching using stack.

773


Can list be null in java?

781


What is primitive data type in java?

748


What are accessor methods in java?

772


When should we create our own custom exception classes?

807


What's the difference between comparison done by equals method and == operator?

763


What is immutability in java?

831


Where pragma is used?

836


What is parse method?

773


What is the static method?

770


When is the finalize() called?

920


Give a brief description of java socket programming?

765


How many types of assembly languages are there?

736


What is passing parameters in java?

751


Explain the differences between static and dynamic variables?

872