Random String Generator Java

  Рет қаралды 72,481

A J

A J

Күн бұрын

Пікірлер: 47
@RahulVerma-bs4bq
@RahulVerma-bs4bq 3 жыл бұрын
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
@yaroslavnochnyk3382
@yaroslavnochnyk3382 4 жыл бұрын
Thank you so much! This video helped me a lot with my test task for the interview! :D Very useful!
@ColinPaddock
@ColinPaddock 6 жыл бұрын
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
@teejay793
@teejay793 3 жыл бұрын
Hi, how can I input the random character generated in a text field on a web page?
@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!!!
@bashardd9254
@bashardd9254 Жыл бұрын
great video! helped me Thanks!
@zeeshanhayder3559
@zeeshanhayder3559 15 күн бұрын
Thanks Andrew
@olenaieriomina4106
@olenaieriomina4106 6 жыл бұрын
Thank you very much for this video!
@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 6 жыл бұрын
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 6 жыл бұрын
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.
@diegorecinos2071
@diegorecinos2071 6 жыл бұрын
Great video!! helps a lot!!
@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?
@musyrics-music9161
@musyrics-music9161 5 жыл бұрын
thanks can you help by implementing this on captcha(offline)
@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?
@saurabhsharma3586
@saurabhsharma3586 4 жыл бұрын
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.
@charjofra6032
@charjofra6032 3 жыл бұрын
how would you do this but in a while loop?
@piper56m35
@piper56m35 6 жыл бұрын
great video! helped me a lot
@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.
@nourmidan2090
@nourmidan2090 6 жыл бұрын
thanks dud really helped
@UniProgrammer
@UniProgrammer 6 жыл бұрын
Glad to hear! Thanks
@KashGamingReal
@KashGamingReal 6 жыл бұрын
Nice video!!!
@behindthescenex
@behindthescenex 7 жыл бұрын
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 6 жыл бұрын
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..
@kirkvanhouten3719
@kirkvanhouten3719 4 жыл бұрын
Thank you so much Bro !!!
@AngelyteMaina
@AngelyteMaina 4 жыл бұрын
THANK YOU!THANK YOU! THANK YOU!
@czs199511
@czs199511 4 жыл бұрын
how about length 0
@mohammadtariq1288
@mohammadtariq1288 5 жыл бұрын
It's a good vedio, but little bit complicated.
@meer_shahrukh7441
@meer_shahrukh7441 3 жыл бұрын
thanks Man
@aljimsonmegrino9580
@aljimsonmegrino9580 5 жыл бұрын
why theres no output when i try to run it sir??
@aljimsonmegrino9580
@aljimsonmegrino9580 5 жыл бұрын
hehehe i figured it out ...thank u
@josemunguia5660
@josemunguia5660 6 жыл бұрын
Thanks bro!
@prod.s23
@prod.s23 6 жыл бұрын
It only did 1 thing
@przemekrosiak3163
@przemekrosiak3163 4 жыл бұрын
thx a lot!!
@nanomeows
@nanomeows 3 жыл бұрын
what the frick frack
@ldelaprade
@ldelaprade 6 жыл бұрын
This is amateur: No insurance 2 calls return different names. Serious programmer had better search for open source java class GUIDGenerator
@UniProgrammer
@UniProgrammer 6 жыл бұрын
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 6 жыл бұрын
@@UniProgrammer Well said.
Why You Shouldn't Nest Your Code
8:30
CodeAesthetic
Рет қаралды 2,8 МЛН
How To Predict Random Numbers Generated By A Computer
13:54
PwnFunction
Рет қаралды 556 М.
FOREVER BUNNY
00:14
Natan por Aí
Рет қаралды 16 МЛН
Trick-or-Treating in a Rush. Part 2
00:37
Daniel LaBelle
Рет қаралды 46 МЛН
Hoodie gets wicked makeover! 😲
00:47
Justin Flom
Рет қаралды 127 МЛН
Java random numbers 🎲 【4 minutes】
4:27
Bro Code
Рет қаралды 170 М.
Java 1 Online, [3.04] Using Classes and Objects: The Random Class
15:47
Michael Madrigal
Рет қаралды 1,1 М.
C++ Random Number Generator AKA STOP USING Rand()
7:20
The Builder
Рет қаралды 59 М.
Object-Oriented Programming is Embarrassing: 4 Short Examples
28:03
Brian Will
Рет қаралды 2,1 МЛН
How to get String Input from a User in Java #12
6:22
Alex Lee
Рет қаралды 270 М.
Java Programming Tutorial - 33 - Interface
16:30
A J
Рет қаралды 2,6 М.
Getting & Formatting the Date/Time in Java
6:45
Kevin's Guides
Рет қаралды 91 М.
FOREVER BUNNY
00:14
Natan por Aí
Рет қаралды 16 МЛН