can you program for reverse string?

Answers were Sorted based on User's Feedback



can you program for reverse string?..

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

can you program for reverse string?..

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

can you program for reverse string?..

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

can you program for reverse string?..

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

can you program for reverse string?..

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

can you program for reverse string?..

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

can you program for reverse string?..

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

Post New Answer

More Core Java Interview Questions

Difference between throw and throws?

0 Answers  


What is :: operator in java?

0 Answers  


Which are the two subclasses under exception class?

0 Answers  


What do you mean by stream pipelining in java 8?

0 Answers  


What are the advantages and disadvantages of object cloning?

0 Answers  






If I don't provide any arguments on the command line, then what will the value stored in the string array passed into the main() method, empty or null?

0 Answers  


How to display all the prime numbers between 1 and n (n is the number, get the input from user)

0 Answers  


What is difference between an object and a class?

0 Answers   Amdocs,


Which container method is used to cause a container to be laid out and redisplayed in java programming?

0 Answers  


There are 2 different ways to create an object. a)By using keyword "new" b)By using Class.forName ("className").newInstance(); What is the difference between these 2 methods.

3 Answers  


What happens when I use / and % with a negative numerator?

0 Answers  


What is java’s garbage collected heap?

0 Answers  


Categories