Translate the provided Python code into Java, ensuring that the core logic and functionality remain identical. Please make sure to follow the following requirements.:
- The translation must be compatible with OpenJDK 17.
- Do not declare package in the Java code.