String Reverse in Java...!

Answer Posted / aravinda reddy

String reverse without using reverse method string class

public class StringReverse {
public static void main(String[] args) {
String str = "Aravind";
StringBuffer s = new StringBuffer();
char[] ch = str.toCharArray();
int n = ch.length;
for(int i=n-1;i>=0;i--)
s.append(ch[i]);
System.out.println(s.toString());
}
}

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a java applet? What is an interface?

874


What is a variable and constant?

787


Is java same as core java?

835


Explain the scope or life time of class variables or static variables?

752


What is the difference between an array and an array list?

746


Write a code to show a static variable?

851


What is the basic concept of java?

786


What is mnemonic in assembly language?

829


What is gui programming?

738


Can a static member function access member variable of an object?

790


What is the default access specifier for variables and methods of a class?

869


Explain the importance of finally over return statement?

840


What are the restrictions imposed by a Security Manager on Applets?.

2334


What are the changes in java.io in java 8 ?

772


How big is a boolean?

811