Write a Java program to demonstrate the use of an interface with default methods for string manipulation
interface StringUtil { default String reverse(String input) { return new StringBuilder(input).reverse().toString(); } default String toUpperCase(String input) { return input.toUpperCase(); } } public class Main implements StringUtil { public static void main(String[] args) { Main main = new Main(); String str = "Tutor Joes"; System.out.println("Reversed String : " + main.reverse(str)); System.out.println("Uppercase String : " + main.toUpperCase(str)); } }
Reversed String : seoJ rotuT Uppercase String : TUTOR JOES
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions