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

What is finally and finalize in java?

0 Answers  


What is java argument list?

0 Answers  


What is the nested interface?

0 Answers  


There are three interfaces A,B & C. A extends B, B extends C, and C extends A.Is it multiple Inheritance? please anybody help me.....

5 Answers  


What is the difference between jvm and jre? What is an interface?

0 Answers  






define System.out.println(); what is the meaning!

19 Answers   Accenture,


What is the final keyword in java?

0 Answers  


what is the difference between thread and runnable types? : Java thread

0 Answers  


What is the declaration statement?

0 Answers  


how to know the total memory occupied by the objects in the ArrayList(Array list may contain duplicate objects)

0 Answers   Infosys, TCS,


What are the Class Libraries ?

0 Answers   Wipro,


for(i=0;i<100;i++) { int i=method();//method returns no's from 1 to 10; /* insert some stmts which can give output like no.of times numbers(1-10) returned. (for example if it returns 2 then i want output how many times 2 returned) like that i want output for no's 1 - 10 how many times each no returned. */ }

3 Answers  


Categories