Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

reverse sentence in java

// INPUT: "you shall not pass"
// OUTPUT: "pass not shall you"
  
String s[] = "you shall not pass".split(" "); 
String ans = ""; 
for (int i = s.length - 1; i >= 0; i--) {
  ans += s[i] + " ";
}
System.out.println(ans);
Source by www.educative.io #
 
PREVIOUS NEXT
Tagged: #reverse #sentence #java
ADD COMMENT
Topic
Name
8+6 =