Code:
class reverseWithoutAPI { public static void main(String a[]) { String str="Java 2 career"; String arr[]=str.split(" "); System.out.print("Reversed String of "+str+":"); for(int i=arr.length-1;i>=0;i--) { char temp[]=arr[i].toCharArray(); for(int j=temp.length-1;j>=0;j--) { System.out.print(temp[j]); } System.out.print(" "); } } }
OUTPUT:
You may also like following string programs:
- A program to reverse a string and change first character case to lower case and last to lower case.
- A program to check String is palindrom or not?
good logic
nice logic…in simple manner..