1. import java.util.ArrayList;
  2. import java.util.List;
  3. class User {
  4. private int id;
  5. private String name;
  6. private String email;
  7. private String address;
  8. public User(int id, String name, String email, String address) {
  9. this.id = id;
  10. this.name = name;
  11. this.email = email;
  12. this.address = address;
  13. }
  14. public int getId() {
  15. return id;
  16. }
  17. public String getName() {
  18. return name;
  19. }
  20. public String getEmail() {
  21. return email;
  22. }
  23. public String getAddress() {
  24. return address;
  25. }
  26. }
  27. public class UserRecordGenerator {
  28. public static List<User> generateUserRecords(int numberOfUsers) {
  29. List<User> users = new ArrayList<>();
  30. for (int i = 0; i < numberOfUsers; i++) {
  31. // Generate some dummy data
  32. int userId = i + 1;
  33. String userName = "User" + userId;
  34. String userEmail = "user" + userId + "@example.com";
  35. String userAddress = "Address " + userId;
  36. User user = new User(userId, userName, userEmail, userAddress);
  37. users.add(user);
  38. }
  39. return users;
  40. }
  41. public static void main(String[] args) {
  42. int numUsers = 10; // Adjust the number of users as needed
  43. List<User> userRecords = generateUserRecords(numUsers);
  44. // Print the generated user records (for verification)
  45. for (User user : userRecords) {
  46. System.out.println("ID: " + user.getId() + ", Name: " + user.getName() + ", Email: " + user.getEmail() + ", Address: " + user.getAddress());
  47. }
  48. }
  49. }

Add your comment