Computer scienceProgramming languagesJavaCode organizationObject-oriented programmingClasses and objectsClasses and members

Records

A new record

Report a typo

Modify the record provided to have a name (String) and an address (String). Note that the order is important.

Sample Input 1:

Diamond
Unknown

Sample Output 1:

Diamond has the address: Unknown
Write a program in Java 17
import java.util.Scanner;

//modify this Record
record Person() {

}

//don't change the code below
class CheckRecord {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
Person person = new Person(scanner.nextLine(), scanner.nextLine());
System.out.println(person.name() + " has the address: " + person.address());
}
}
___

Create a free account to access the full topic