1. Colin Paddock on April 7, 2020 at 9:17 am

    Because String objects are immutable, each concatenation is going to create a whole new String, which is a bad habit to build if you have any intention of doing anything large-scale. There is a String(char[]) constructor, which can do what that second loop does rather more cleanly.

    It’s also a waste of time to create a random string of zero length, so line 15 in your modified version should be
    int length = rand.nextInt(14) + 1;
    , which will produce a random string of length 0<length<15.

  2. Alexander Calderon on April 7, 2020 at 9:18 am

    You could’ve added "randomString += text[i];" in the first loop.

  3. jose munguia on April 7, 2020 at 9:30 am

    Thanks bro!

  4. rahul pandit on April 7, 2020 at 9:32 am

  5. musyrics - music on April 7, 2020 at 9:33 am

    thanks can you help by implementing this on captcha(offline)

  6. Kash on April 7, 2020 at 9:35 am

    Nice video!!!

  7. Reshan Maduka on April 7, 2020 at 9:38 am

    public class generate {

    * @param args the command line arguments
    public static void main(String[] args) {
    // TODO code application logic here

    String characters="abcdefghijklmnopqrstuvwxyz!#$%^&*()-=+|`ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";

    String randomString="";

    int length=5;

    Random rand=new Random();

    char[] text =new char[length];

    for (int i = 0; i < length ; i++) {

    for (int i = 0; i < text.length; i++) {
    randomString +=text[i];


  8. stephanie sutton on April 7, 2020 at 9:43 am

    Hi I have a list words and phrases of various lengths I would like to create a generator for in java. Is this even possible? If so, how please?

  9. Mohammad Tariq on April 7, 2020 at 9:43 am

    It’s a good vedio, but little bit complicated.

  10. Laurent de Laprade on April 7, 2020 at 9:43 am

    This is amateur: No insurance 2 calls return different names. Serious programmer had better search for open source java class GUIDGenerator

  11. Diogo Menino Porta-Nova on April 7, 2020 at 9:43 am

    I had problems with the initialize of the variable i. I use a text editor and the prompt command at linux and it says that cannot find the variable i. I’ve write it like it was in the video. What is the matter where?? I appreciate your help, thx!!!

  12. Jelly on April 7, 2020 at 9:54 am

    It only did 1 thing

  13. Maggie Pio on April 7, 2020 at 9:59 am

    great video! helped me a lot

  14. Gede Arya Indra Prabawa on April 7, 2020 at 10:00 am

    thank you so much for the video andrew ! i’m sorry to ask you again. i’ve got one more question, if i got an array of string like this :

    String [ ] symbols = {"heart", "diamond", "clubs", "spades"};

    how can i random the values of the array ? i’ve tried to loop the values and then stored it on an array list, but still i’ve got incompatible types message. here’s my code :

    String [] symbol = {"heart" , "diamond" , "clubs" , "spades"};
    Random rand = new Random();
    ArrayList <String> store = new ArrayList <String> ();

    for(int i = 0; i < symbol.length; i++ ){

    could you help for this ? sorry to make trouble andrew, thank you so much for the tutorial once again :))

  15. NOUR MIDAN on April 7, 2020 at 10:02 am

    thanks dud really helped

  16. Animelover Jimson on April 7, 2020 at 10:02 am

    why theres no output when i try to run it sir??

  17. Semper Paratus on April 7, 2020 at 10:04 am

    mate what if its a random generated id number? should i change the string to int? then what should be the numbers like 0-10000?

  18. Yaroslav Nochnyk on April 7, 2020 at 10:05 am

    Thank you so much! This video helped me a lot with my test task for the interview! 😀
    Very useful!

  19. Diego Recinos on April 7, 2020 at 10:07 am

    Great video!! helps a lot!!

  20. Olena Ieriomina on April 7, 2020 at 10:14 am

    Thank you very much for this video!