public class Demo1 {
public static void main(String[] args) {
String s="MSK Technologies";
String[] words = s.split(" ");
int x,y;
String reverseString = "";
for ( x = 0; x < words.length; x++)
{
String word = words[x];
String reverseWord = "";
for ( y = word.length()-1; y >= 0; y--)
{
reverseWord = reverseWord + word.charAt(y);
}
reverseString = reverseString + reverseWord + " ";
}
System.out.println(s);
System.out.println(reverseString);
}
}
Output:
KSM seigolonhceT
more programs visit http://sateeshm.com/
No comments:
Post a Comment