017-006-009

Combining Function and Consumer

Medium

Problem Description

Combining Function and Consumer

In this problem, you will create a program that combines two functional interfaces — a Function<String, String> to convert strings to uppercase and a Consumer<String> to decorate and display the result — and displays the result to standard output.

Learning Objective: Understand how to combine Function<T,R> and Consumer for data transformation and output

Overview

Create a Function to convert strings to uppercase and a Consumer to decorate and output the result.

Specifications

  • Function<String, String> type toUpperCase: converts string to uppercase
  • Consumer<String> type printer: outputs with "[OUTPUT] " prefix
  • Convert and output "hello" and "world"

Output Format

[OUTPUT] HELLO
[OUTPUT] WORLD

Ready to Try Running Code?

Log in to access the code editor and execute your solutions for this problem.

Don't have an account?

Sign Up