can you program for reverse string?

Answer Posted / narayanan

public class reverse {
public static void main(String args[]){

String s="malayalam";
StringBuffer sb=new StringBuffer();
int k=s.length();
for (int i = k-1; i >-1; i--) {
sb.append(s.charAt(i));

}
System.out.println(sb);
}

}

Is This Answer Correct ?    9 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a superclass?

935


What do you understand by weak reference?

563


What is immutable in java?

555


What is difference between an object and a class?

617


Explain what access modifiers can be used for methods?

574






Explain purpose of sleep() method in java?

628


Can we access instance variables within static methods ?

582


What is the difference between a synchronized method and a synchronized block?

620


What are the main uses of the super keyword?

560


What is overloading and overriding in java?

668


Given a singly linked list, find the middle of the list in a single traversal without using temporary variable.

619


How many functional interfaces does java 8 have?

610


What is the functionality of the stub?

579


Why are there no global variables in java?

595


Which class cannot be a subclass in java?

551