forked from dharmanshu1921/Java
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathString_Reverse.java
More file actions
Latest commit
17 lines (16 loc) · 447 Bytes
/
Copy pathString_Reverse.java
File metadata and controls
17 lines (16 loc) · 447 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
importjava.util.*;
publicclassstringreverse {
publicstaticvoidmain(String[] args) {
Scannersc= newScanner(System.in);
System.out.print("Enter a string: ");
Stringstr= sc.nextLine();
String[] strArray = str.split(" ");
for (Stringtemp: strArray){
System.out.println(temp);
}
for(inti=0; i<3; i++){ char[] s1 = strArray[i].toCharArray(); for (intj = s1.length-1; j>=0; j--)
{System.out.print(s1[j]);}
System.out.print(" ");
}
}
}