Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class StringReverse
- {
- public static void main(String[] args) throws java.io.IOException
- {
- int str[] = new int[100];
- int i=0,j;
- System.out.println("Enter a string");
- while(true)
- {
- str[i]=System.in.read();
- if(str[i++]==13)
- break;
- }
- String reversed="",simple = new String(str,0,i-1);
- System.out.println(simple);
- // now reversing the string
- for(j=i-1;j>=0;j--)
- reversed+=((char)str[j]);
- System.out.println(reversed);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement