String Reversal in Java using While Loop.

String Reversal in Java using While Loop.

Program

public class strreva {

public static void main(String[] args) {
// TODO Auto-generated method stub
String a = "wererrer";
String b ="";
int j = a.length()-1;
while(j>=0){
b = b+ a.charAt(j);
j--; 
}
System.out.println("b is "+b );
}

}

Output


b is rerrerew
String Reversal in Java using While Loop. String Reversal in Java using While Loop. Reviewed by imran ahmed on 4:40 AM Rating: 5

No comments:

Gallery

Powered by Blogger.