can you program for reverse string?
Answers were Sorted based on User's Feedback
Answer / raj
public static void main (String args[])
{ String s1="1234567";
for(int i=s1.length()-1;i>=0;i--)
{
System.out.print(s1.charAt(i));
}
}
Is This Answer Correct ? | 25 Yes | 0 No |
Answer / 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 |
Answer / indumathi
public class StringReverseExample {
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);
}
}
Is This Answer Correct ? | 9 Yes | 5 No |
Answer / suswagata choudhury
public class Reverse {
public static void main(String args[]){
String s="SUSWAGATA";
StringBuffer sb=new StringBuffer(s);
System.out.println(sb.reverse());
}
}
Is This Answer Correct ? | 3 Yes | 1 No |
Answer / pratyush kumar nayak
String Original,Reverse="";
System.out.println("Enter String To Reverse");
Scanner sc=new Scanner(System.in);
Original=sc.nextLine();
int length=Original.length();
for(int i=length-1;i>=0;i--){
Reverse=Reverse+Original.charAt(i);
}
System.out.println("The Reversed String is " + Reverse);
Is This Answer Correct ? | 0 Yes | 0 No |
Answer / suresh
class suresh
{
public static void main(String args[])
{
String s="sureshreddy";
for(i=s.length()-1;i>=0;i--)
{
System.out.println(s.charAt(i));
System.out.println(s.length());//it wil print the length
}
}
}
Is This Answer Correct ? | 0 Yes | 1 No |
Answer / caughtme
say string s1="1234567";
for(int i=s1.length()-1;i<=0;i--)
{
System.out.Println(CharAt[i].toString());
}
Is This Answer Correct ? | 0 Yes | 15 No |
What is argument in java?
What is the argument in java?
Can we extend immutable class?
how would you implement a thread pool? : Java thread
What is meant by inheritance and what are its advantages?
What is replaceall in java?
Why should I use abstract class?
What are the different data types in java?
Explain the difference between serializable and externalizable in java?
What is difference between compatible and incompatible changes in serialization?
What is 16 bits called?
What is threaded programming and when is it used? : Java thread