I get an error in Java at compile time:
UserID.java:36: error: incompatible types
+ generator.nextInt(10);
^
required: String
found: int
Here is the Java code:
public class UserID {
private String firstName;
private String userId;
private String password;
public UserID(String first) {
Random generator = new Random();
userId = first.substring(0, 3) +
+ generator.nextInt(1) +
(generator.nextInt(7) + 3) + generator.nextInt(10);
password = generator.nextInt(10) + generator.nextInt(10);
}
}
What is the cause of this error and how to fix it? Why doesn't this automatically push int to String?
source
share