UPPER TO LOWER CASE USING LAMBDA FUNCTIONS
Wed May 29 2024 16:48:11 GMT+0000 (Coordinated Universal Time)
Saved by
@signup
import java.util.Scanner;
import java.util.function.Function;
public class LambdaStringCase {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter a string: ");
String input = scanner.nextLine();
Function<String, String> toUpperCase = str -> str.toUpperCase();
Function<String, String> toLowerCase = str -> str.toLowerCase();
String upperCaseString = toUpperCase.apply(input);
System.out.println("Uppercase: " + upperCaseString);
String lowerCaseString = toLowerCase.apply(input);
System.out.println("Lowercase: " + lowerCaseString);
}
}
content_copyCOPY
Comments