Тёмный

Random String Generator Java 

A J
Подписаться 3,1 тыс.
Просмотров 72 тыс.
50% 1

This video shows one way of many ways to construct a random string in Java.
The concepts in this video are taken from the first few videos in my "Java Tutorials for Beginners" playlist.
Thank you for your questions! Hope this helps!

Наука

Опубликовано:

 

7 ноя 2017

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 46   
@yaroslavnochnyk3382
@yaroslavnochnyk3382 4 года назад
Thank you so much! This video helped me a lot with my test task for the interview! :D Very useful!
@diegorecinos2071
@diegorecinos2071 6 лет назад
Great video!! helps a lot!!
@RahulVerma-bs4bq
@RahulVerma-bs4bq 2 года назад
Thank you so much bro. It was a nice explanation and the best part is you made it look so simple. Keep up the good wok
@piper56m35
@piper56m35 5 лет назад
great video! helped me a lot
@bashardd9254
@bashardd9254 Год назад
great video! helped me Thanks!
@kirkvanhouten3719
@kirkvanhouten3719 4 года назад
Thank you so much Bro !!!
@AngelyteMaina
@AngelyteMaina 4 года назад
THANK YOU!THANK YOU! THANK YOU!
@olenaieriomina4106
@olenaieriomina4106 6 лет назад
Thank you very much for this video!
@KashGamingReal
@KashGamingReal 5 лет назад
Nice video!!!
@josemunguia5660
@josemunguia5660 6 лет назад
Thanks bro!
@Digas27PT
@Digas27PT 5 лет назад
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!!!
@teejay793
@teejay793 3 года назад
Hi, how can I input the random character generated in a text field on a web page?
@xMrTdLx
@xMrTdLx 4 года назад
The modified version of your code generates a random string from 0 - 15. How would you go about it, if you wanted your code to generate a random string that has a character length of 14 -19?
@nourmidan2090
@nourmidan2090 5 лет назад
thanks dud really helped
@UniProgrammer
@UniProgrammer 5 лет назад
Glad to hear! Thanks
@musyrics-music9161
@musyrics-music9161 5 лет назад
thanks can you help by implementing this on captcha(offline)
@przemekrosiak3163
@przemekrosiak3163 3 года назад
thx a lot!!
@ColinPaddock
@ColinPaddock 5 лет назад
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
@meer_shahrukh7441
@meer_shahrukh7441 3 года назад
thanks Man
@behindthescenex
@behindthescenex 6 лет назад
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 store = new ArrayList (); for(int i = 0; i < symbol.length; i++ ){ store.add(rand.nextInt(symbol[i])); } could you help for this ? sorry to make trouble andrew, thank you so much for the tutorial once again :))
@DRsewage
@DRsewage 5 лет назад
String[] symbol = {"thing1", "thing2", "thing2"}; Random rand = new Random(); System.out.println(symbol[rand.nextInt(symbol.length)]); Something like that. You dont need to make another Array for that, or I just dont know what you want to achive. and instead of System.out you can just write something like String CPU = symbol[rand.nextInt(symbol.length)]; And that's it. If its for the game I quess..
@astiginko
@astiginko 4 года назад
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?
@charjofra6032
@charjofra6032 2 года назад
how would you do this but in a while loop?
@alexandercalderon3040
@alexandercalderon3040 6 лет назад
You could've added "randomString += text[i];" in the first loop.
@UniProgrammer
@UniProgrammer 6 лет назад
Yes, good catch. That would work too. In this instance I was keeping the steps simple to show its functionality.
@ColinPaddock
@ColinPaddock 5 лет назад
You could also have skipped creating the array in that case. Simply make the contents of the first loop randomString += characters.charAt(rand.nextInt(characters.length()));
@ColinPaddock
@ColinPaddock 5 лет назад
That would once again have the problem of creating myriads of superfluous String instances, so it’s still better to build the array and then use the String constructor overload with the char array input. This also avoids creating the superfluous empty String at the start.
@mohammadtariq1288
@mohammadtariq1288 5 лет назад
It's a good vedio, but little bit complicated.
@saurabhsharma3586
@saurabhsharma3586 3 года назад
can we generate all possible combination throw random. you are printing only one combination. but i want to print all possible combination. like(ABCD, ABCE,ACED..............) SO ON. CAN YOU HELP ME ON THIS.
@czs199511
@czs199511 3 года назад
how about length 0
@aljimsonmegrino9580
@aljimsonmegrino9580 4 года назад
why theres no output when i try to run it sir??
@aljimsonmegrino9580
@aljimsonmegrino9580 4 года назад
hehehe i figured it out ...thank u
@prod.s23
@prod.s23 5 лет назад
It only did 1 thing
@user-ec6ej4dp6t
@user-ec6ej4dp6t Год назад
This makes sense but does not solve what is expected of me with my project currently. Teacher wants me to have 3 words and then generate random output of the 3 words
@UniProgrammer
@UniProgrammer Год назад
Instead of the full alphabet, you could set the list of characters to be the three words. This can be done dynamically from user input or hard-coded prior to execution.
@paniewa3271
@paniewa3271 3 года назад
what the frick frack
@ldelaprade
@ldelaprade 5 лет назад
This is amateur: No insurance 2 calls return different names. Serious programmer had better search for open source java class GUIDGenerator
@UniProgrammer
@UniProgrammer 5 лет назад
Laurent de Laprade Thanks for your constructive feedback. However this tutorial set is intended for programmers who are at the beginner level. Hence I used concepts only covered in the beginning stages of my java tutorials. Additionally, understanding the fundamental concepts of programming is much more important for a beginner programmer than being the most efficient. Efficiency comes with knowledge and experience... not java tutorial videos.
@8tzgaming907
@8tzgaming907 5 лет назад
@@UniProgrammer Well said.
Далее
How To Predict Random Numbers Generated By A Computer
13:54
C++ Random Number Generator AKA STOP USING Rand()
7:20
Самоприкорм с сестрой 😂
00:19
Просмотров 264 тыс.
С Анджилишей на тусе💃
00:15
Просмотров 133 тыс.
Java random numbers 🎲 【4 minutes】
4:27
Просмотров 149 тыс.
Java Program #19 - Generate Random Numbers in Java
6:20
Java Programming Tutorial - 33 - Interface
16:30
Просмотров 2,6 тыс.
Using Java's Math.random() Method
5:13
Просмотров 39 тыс.
Java Program That Generate Random String
2:57
Просмотров 8 тыс.
Mac Studio из Китая 😈
0:34
Просмотров 91 тыс.
Самый СТРАННЫЙ смартфон!
0:57
Просмотров 31 тыс.