Override the default getters in the Player record. The getter for username should return the username in uppercase while the getter for email should return it in lowercase.
Computer scienceProgramming languagesJavaCode organizationObject-oriented programmingClasses and objectsClasses and members
Records
Application
Report a typo
Write a program in Java 17
import java.util.Scanner;
record Player(String username, String email) {
}
class OverrideTest {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
Player player = new Player(scanner.next(), scanner.next());
System.out.println(player.username() + ":" + player.email());
}
}
___
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.
Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.