Computer scienceProgramming languagesJavaCode organizationObject-oriented programmingClasses and objectsClasses and members

Records

Personal records

Report a typo

Print the attributes of the Person record in the following format: "name is age years old and is gender"

Sample Input 1:

Miku 16 female

Sample Output 1:

Miku is 16 years old and is female
Write a program in Java 17
import java.util.Scanner;

record Person(String name, int age, String gender) {
//don't change this record
}

public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
Person person = new Person(scanner.next(), scanner.nextInt(), scanner.next());

// your code goes here

}
}
___

Create a free account to access the full topic