Computer scienceProgramming languagesJavaCode organizationObject-oriented programmingClasses and objectsClasses and members

Records

Application

Report a typo

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.

Sample Input 1:

Sample Output 1:

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());
}
}
___

Create a free account to access the full topic