+ 1
Creating username
What is wrong with my code? I'm looking to create a username based on my name and surname and random numbers. https://code.sololearn.com/cnDtzfYd8Cjp/?ref=app
4 Réponses
+ 4
import java.util.Random;
import java.util.*; // your mistake, java.util*
public class MyUsername{
public static void main(String[] args) {
String first = "emma";
String last = "mbambo";
Random genarate = new Random();
int myNumber = genarate.nextInt(70) + 11;
String username = first.charAt(0) + last.substring(0, 5) + myNumber; // Your mistake, put declaration of username first.
System.out.println(username);
}
}
+ 2
ShortCode Thanks
+ 2
Rstar great job!