In financial systems, raw data must often undergo specific transformations and formatting before being presented to the user. This project demonstrates the Function<T, R> functional interface. We implement a formatting pipeline that doubles a numerical value and prepends a standard prefix. This illustrates the core functional concept of "mapping" — converting an input of one type (Integer) into a result of another type (String).
-
Standard Tooling: Utilized
java.util.function.Function<Integer, String>for type-safe transformation. -
Value Transformation: Implemented logic to double the input value (
$x \times 2$ ). - String Concatenation: Integrated a fixed prefix "Result: " into the final output.
- Clean Code: Followed naming conventions and structural templates required.
- Java 8+ (Standard Functional Interfaces, Generics, Lambdas)
- Function<Integer, String>: The contract that takes an Integer and returns a String.
- ReportLauncherApp: The entry point providing the data and printing the formatted result.
Result: 14
Project Structure:
JavaBasics_Task_368/
├── src/
│ └── com/yurii/pavlenko/
│ └── app/
│ └── ReportLauncherApp.java
├── LICENSE
├── TASK.md
├── THEORY.md
└── README.md
Code
package com.yurii.pavlenko.app;
import java.util.function.Function;
public class ReportLauncherApp {
public static void main(String[] args) {
final String prefix = "Result: ";
Function<Integer, String> reportFormatter = value -> {
int doubled = value * 2;
return prefix + doubled;
};
String finalRow = reportFormatter.apply(7);
System.out.println(finalRow);
}
}This project is licensed under the MIT License.
Copyright (c) 2026 Yurii Pavlenko
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files...
License: MIT