Java program to reverse a sentence
Problem Write a java program to: Reverse a sentence by letters Reverse a sentence by words Reverse Sentence by letters Code public class Main { public static void main(String[] args) { String sentence=“Welcome to java”; System.out.println(reverseByLetters(sentence)); } public static String reverseByLetters(String sentence){ char[] c=sentence.toCharArray(); String out=“”; for (int i=c.length–1;i>=0;i—){ out+=c[i]; } return out; } } Output avaj ot emocleW Explanation First, we broke the String sentence into characters by calling the toCharArray() function on the string. … Read more Java program to reverse a sentence