User user = new User(); user.setUsername("john.doe");
User user = new User(); user.setUsername("jane.smith"); // Changing the username of the user object user.setUsername("jane.doe");
User user = new User(); user.setUsername("john.doe"); // Getting the username of the user object String username = user.getUsername();The User class is a standard class in Java, which is included in the java.lang package. Therefore, there is no need to import a separate package library to use the setUsername() method.