Java random numbers 🎲 【4 minutes】

  Рет қаралды 176,699

Bro Code

Bro Code

Күн бұрын

Пікірлер: 282
@BroCodez
@BroCodez 4 жыл бұрын
import java.util.Random; public class Main { public static void main(String[] args) { Random random = new Random(); int x = random.nextInt(6)+1; //double y = random.nextDouble(); //boolean z = random.nextBoolean(); System.out.println(x); } }
@nagapranithasamudrala2224
@nagapranithasamudrala2224 3 жыл бұрын
I am unable to convert it into int . It is showing that random cannot be converted to int
@apurbaganguly9957
@apurbaganguly9957 3 жыл бұрын
This code is giving error
@Blackoutfor10days
@Blackoutfor10days 2 жыл бұрын
Can we generate random character
@waage_yt
@waage_yt Жыл бұрын
"Random random, equals new random. That's random." Wise words from our savior.
@shift-g3l
@shift-g3l 5 ай бұрын
wise words from a wise man
@serkan7419
@serkan7419 3 жыл бұрын
random.nextInt(max - min + 1) + min ; //creates number between two numbers
@3omarhd878
@3omarhd878 2 жыл бұрын
cant understand can someone say more details ?
@domenicdemski1436
@domenicdemski1436 Жыл бұрын
@@3omarhd878 say you want a random integer from 30-100. If we say int max = 100; and int min = 30; when we take the difference of those two, we will be passing 70 into the nextInt method. Note that this will only find a random number from 0-69 now, so we must add 1 inside the parentheses. Our value will now be between 0-70. Adding the min integer afterwards then allows us to generate a number from 30-100.
@muratcangozum2589
@muratcangozum2589 Жыл бұрын
Nice
@3omarhd878
@3omarhd878 Жыл бұрын
@@domenicdemski1436 thank you
@domenicdemski1436
@domenicdemski1436 Жыл бұрын
@@3omarhd878 gotchu
@aya2222
@aya2222 3 жыл бұрын
These videos are super helpful for self taught beginner! I'm not native English speaker but I could follow your tutorials without any problem thanks to your clear explanation. Thank you so much! I would like to join your class if you have one.
@Daniel_MZA
@Daniel_MZA 3 жыл бұрын
I´m not a native English speaker but this guy explains super! I mean I can understand English and this guy does and describes his hobby very understandable.
@manipurihunabopa
@manipurihunabopa Жыл бұрын
Everything after Bro Code teaches becomes easy.
@emmalund7859
@emmalund7859 2 жыл бұрын
I'm so glad I found you! Straight to the point and well explained. Thank you so much!
@aaronjackson7942
@aaronjackson7942 Жыл бұрын
Im so happy my friend sent me to your channel, im 32 and ready to have a career change. I have been so addicted to java since starting these video's! thank you brO!
@pavelkvasnicka6856
@pavelkvasnicka6856 Жыл бұрын
This is the best Java tutorial for beginners, so you can learn Java and English in one hit. Please keep going! I vote for Java advance tutorial. Thanks a lot Bro
@achristopoulos
@achristopoulos 4 жыл бұрын
The random double numbers have various usages for example statistics , probability etc.
@brendanr8828
@brendanr8828 2 жыл бұрын
Ty
@Abdulrahman-hb6fy
@Abdulrahman-hb6fy 23 күн бұрын
I suppose we can use it even in gaming, like Pack Luck in FIFA for instance
@xplane7879
@xplane7879 3 жыл бұрын
Me le coding: Random rand = new Random(); String s = rand.nextString(); KZbin.out.comment(s); KZbin: Channel recommendation improved... Me: Wow it worked... 😍🙏
@juanestebanparraparra6302
@juanestebanparraparra6302 3 жыл бұрын
I cant helpt it but returning to your videos whenever I wanna learn programming. Thanks Bro!
@Mr.beezet
@Mr.beezet 2 ай бұрын
I love you classes bro, it really helps
@BLUEDAWNNN
@BLUEDAWNNN 2 ай бұрын
These videos are super helpful for self taught beginner!
@ShahriyarAlam1
@ShahriyarAlam1 2 жыл бұрын
I've always just used Math.random() and for a dice I normally just do double randomDouble = Math.random() * 6; and then do integer randomInt = (int)randomDouble; and then randomInt++;
@ejay
@ejay Жыл бұрын
Why not just cast it in the first one int random =(int)(Math.random()*6);
@venkatasrikarkavuri2089
@venkatasrikarkavuri2089 2 жыл бұрын
I am so excited because new shrek movie was announced by the official twitter page saying Morbin' time is over and its time for shrek to play some shreksophone
@skyset_
@skyset_ 11 ай бұрын
how random of you!
@annderby6295
@annderby6295 3 жыл бұрын
Now I know how random number generation works for different data types. Thanks.
@Islem_ch123
@Islem_ch123 4 ай бұрын
I'm not even good at english ethier at programming but i really like this channel it help me allot to understand java even when he speak English I'm so grateful that i found you broo thank you so much 🙏
@MAULIKPATELnamste
@MAULIKPATELnamste 4 жыл бұрын
This is GOOD !!! Variety of JAVA courses.
@TheDuckter
@TheDuckter 11 ай бұрын
"Random random, equals new random. That's random." I agree. Thats random.
@Daniel_MZA
@Daniel_MZA 3 жыл бұрын
Thanks! :) I would like to see videos about kotlin :) , But this java course I really like it :).
@Barak_Mozes
@Barak_Mozes 2 жыл бұрын
Hey brother, you are a genius, I wish you all the best, thank you
@DesiHabibi
@DesiHabibi 3 жыл бұрын
thx for vids !
@filipkuchta_main
@filipkuchta_main Жыл бұрын
Finally answers without a need to read 10 pages manual.
@chsaireddy22
@chsaireddy22 Жыл бұрын
I wish I wanna go past and all my teachers are be like him 🥺 Such a great explanation lot's of Gratitude to you " BRO "
@MAULIKPATELnamste
@MAULIKPATELnamste 4 жыл бұрын
This Randomness of the Universe really is helping me
@TheErry98
@TheErry98 4 жыл бұрын
How can i generate a random value between -6 to 6 for example?
@BroCodez
@BroCodez 4 жыл бұрын
int max = 6; int min = -6; int x = random.nextInt((max+1) + max) + min;
@kelleyannbart8348
@kelleyannbart8348 Жыл бұрын
Very helpful videos, thank you!!
@emdorsfm1625
@emdorsfm1625 2 жыл бұрын
I already know alot about programing so the first like 5 vids becuz i know about Strings variables Char boolean etc. but after that it gets realy exiting i realy like java and i would love to master it and with you its so much easy thanks alot
@MC_Transport
@MC_Transport 6 ай бұрын
4:20 A random comment
@gabriellopes4361
@gabriellopes4361 Жыл бұрын
thank god for these channels dude... even tho im a atheist ! this video has 4 minutes but explains a lot !
@melo1722
@melo1722 Жыл бұрын
int x= random.nextInt(6)+8 what happens then??
@antoniopedroaraujo7403
@antoniopedroaraujo7403 7 ай бұрын
You get a random number between 7 and 12
@flacko2191
@flacko2191 Ай бұрын
import java.util.Random; class Main { public static void main(String[] args) { Random random = new Random(); int x = random.nextInt(3); double y = random.nextDouble(); boolean z = random.nextBoolean(); System.out.println(x); System.out.println(y); System.out.println(z); } }
@o0QuAdSh0t0o
@o0QuAdSh0t0o Жыл бұрын
3:40 made me lol
@Madara2B
@Madara2B 3 жыл бұрын
decided to make it do 100, got a 69 on my 3rd roll. Worth it
@catman4001
@catman4001 2 жыл бұрын
sigma grindset
@Simis999
@Simis999 2 жыл бұрын
Nobody: Random: Curd would book a star had the Oscars seen Additional Mouse Properties.
@JuliHoffman
@JuliHoffman 2 жыл бұрын
I can make my own random number generator! I know this is kid stuff, but I'm so ridiculously happy right now.
@gamingzonezone1
@gamingzonezone1 Ай бұрын
Hi Juli can we be friends because I want to learn speak english
@mustafaismail9802
@mustafaismail9802 2 жыл бұрын
The Random Hypotenuse 😁😁😁 import javax.swing.JOptionPane; import java.util.Random; public class Main { public static void main(String[] args) { Random random = new Random(); int x = random.nextInt(100); System.out.println("value of x : " + Math.abs(x)); int y = Math.abs(random.nextInt(100)); System.out.println("value of y : " + y); int z = (int) Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2)); System.out.println("The Hypotenuse is : " + z); } }
@gamesandsoftwares1441
@gamesandsoftwares1441 2 жыл бұрын
doing my part for the algorithm AGAIN while (watching bro code){smash that like button};
@abdulalimmahir
@abdulalimmahir 3 жыл бұрын
string comment = random.nextOpinion(); Sysout(comment, "Java is a girl, so descriptive");
@user-ex1zu1re1g
@user-ex1zu1re1g 2 жыл бұрын
hello, i would like to generate a random number from a specific set for example { 1,6,77,90,39 } how would i code it?
@PedroSilva-rn6ux
@PedroSilva-rn6ux 2 жыл бұрын
Hi, Did you make it?
@paprikar
@paprikar 2 жыл бұрын
@@PedroSilva-rn6ux just generate a random number-index, by which you get the desired number from the list
@gabeishere4990
@gabeishere4990 Жыл бұрын
Giga Chad thumbnail in 2020? Very Chad like.
@moussaei1390
@moussaei1390 Жыл бұрын
Guys please how to give that number a percentage for not showing up
@ayhangumus9877
@ayhangumus9877 2 жыл бұрын
Thanks for the help before the test.
@code_dynamic8211
@code_dynamic8211 2 жыл бұрын
Nice tutorial you got there :D
@mkhyperltd
@mkhyperltd 3 жыл бұрын
Moment of silence for the poor souls who disliked our Bros Videos. All of you 15,928 ungrateful viewers as well.
@trickysachin
@trickysachin 3 жыл бұрын
Your videos are informative and interesting
@diegocharrycardenas457
@diegocharrycardenas457 2 жыл бұрын
Thanks bro great tutorial !
@josephstaples8186
@josephstaples8186 2 жыл бұрын
This is the best video I have ever seen
@honoredegg
@honoredegg 2 жыл бұрын
Random understood. 8th. Thank you, ma Bro Sensei!
@AliiaAbdieva
@AliiaAbdieva 2 жыл бұрын
thank you for great lesson
@CodeTV-oy9sq
@CodeTV-oy9sq Жыл бұрын
thx for the knowledge!
@rajuveerla713
@rajuveerla713 2 жыл бұрын
how do i take range as an input from user
@emmanueljr
@emmanueljr 2 жыл бұрын
Can anyone explain how random.nextInt(6)+1 gives us a range of 1-6? I thought we’d now be getting a range of 0-7
@bryanZ17
@bryanZ17 2 жыл бұрын
I'm not 100 percent sure either buy maybe since the starting value is always 0, then by adding +1, it changes the starting value to 1? 🤔
@emmanueljr
@emmanueljr 2 жыл бұрын
@@bryanZ17 Yup, makes sense. Thank you
@zapeeosheikh
@zapeeosheikh 3 жыл бұрын
@Bro Why we write. (6)+1; We are taking 6 values for a dice so 0 - 6 = 7 values +1 = 8 Is it ??
@dildosti7769
@dildosti7769 3 жыл бұрын
Random(6); means Start from 0 to end at 6 ...... Random(6)+1; means Start from 1 to end at 6 .......
@4exan599
@4exan599 3 жыл бұрын
@@dildosti7769 Random(6); means Start from 0 to end at 5*
@shaysoggy1661
@shaysoggy1661 Жыл бұрын
Striaght to the point Thanks bro👍
@freddestiny1890
@freddestiny1890 4 жыл бұрын
Hi,how can i generate a string where the first two characters are letters while the rest are numbers(example: "AX10532"). I need this to generate vehicle license plates.
@BroCodez
@BroCodez 4 жыл бұрын
What I would do is to create a string of all the characters you want to use: String myString = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" Use the random class to create random integers randomNum = random.nextInt(10) randomLetter = random.nextInt(26)+10 Then use the myString.charAt(randomNum) method to pick a random number from the string myString.charAt(randomLetter) method to pick a random letter from the string
@epikurus6913
@epikurus6913 2 жыл бұрын
@@BroCodez this is a year old but its pretty cool you reached out with such a specific answer, real bro code
@sairos4057
@sairos4057 2 жыл бұрын
@@BroCodez I tried to compile this but I got a error. Maybe I'm stupid.
@darkpal1339
@darkpal1339 2 жыл бұрын
Thanks to your question I was able to get some good practice! Here is how I did it String myString = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; Random randomNum = new Random(); String newString = String.valueOf(myString.charAt(randomNum.nextInt(10)+26)) + String.valueOf(myString.charAt(randomNum.nextInt(10)+26)) + String.valueOf(myString.charAt(randomNum.nextInt(10))) + String.valueOf(myString.charAt(randomNum.nextInt(10))) + String.valueOf(myString.charAt(randomNum.nextInt(10))) + String.valueOf(myString.charAt(randomNum.nextInt(10))) + String.valueOf(myString.charAt(randomNum.nextInt(10))); //"String.valueOf" converts char to String System.out.println(newString);
@stray1239
@stray1239 2 жыл бұрын
"a random comment"
@deeplife9654
@deeplife9654 Жыл бұрын
love for helping you beat algorithem.
@jasoncrypto4848
@jasoncrypto4848 2 жыл бұрын
what name this program so i can download it
@gregorythegrimreaperscarpa3415
@gregorythegrimreaperscarpa3415 Жыл бұрын
How to generate random numbers between 0 to 1?
@sanjaykarmakar100
@sanjaykarmakar100 3 жыл бұрын
1:18 Really Random!
@NkosiHadebe-k5t
@NkosiHadebe-k5t 2 жыл бұрын
hello this video was super helpful, can you please tell me how you changed your background to dark mode? @Bro Code
@Пирамидакуба
@Пирамидакуба 2 жыл бұрын
There is the first video about java, so at the end of it you can find this info.
@PavneetSingh-o8z
@PavneetSingh-o8z 2 ай бұрын
very short and helpful video
@UmeshKumar-zh8wk
@UmeshKumar-zh8wk 3 жыл бұрын
I have written the same code using intelliJ but error comes???
@zapeeosheikh
@zapeeosheikh 3 жыл бұрын
Make sure either you are importing the Library or not
@cornmoss638
@cornmoss638 3 жыл бұрын
RNG! import java.util.Random; /*Brandon (Insert Last Name Here) *March 27, 2021 *Intro to RNG */ public class RandomValues { public static void main(String[] args) { Random random = new Random(); int x = random.nextInt(6) + 1; double y = random.nextDouble(); boolean z = random.nextBoolean(); System.out.println(x); System.out.println(y); System.out.print(z); }//end of main }//end of class
@meghashah5473
@meghashah5473 2 жыл бұрын
Superb my Random bro
@Dev-PauloEd
@Dev-PauloEd 3 жыл бұрын
I want to play video games, but my father won't let me do it because he thinks that it's Satan's thing
@zapeeosheikh
@zapeeosheikh 3 жыл бұрын
What is the purpose of Scanner.close();
@We-tz8ko
@We-tz8ko 3 жыл бұрын
to close the scanner class imported from java
@Anupama_Mondal85
@Anupama_Mondal85 Ай бұрын
Good explanation
@BurhanTosuner
@BurhanTosuner 2 жыл бұрын
ellerinize sağlık güzel olmuş. kısa ve öz
@afrobear2310
@afrobear2310 3 ай бұрын
Drop a pseudo-random comment guys !!!
@wallstreetbets7741
@wallstreetbets7741 2 жыл бұрын
thx i learnt dfro u again
@Savahax
@Savahax 2 ай бұрын
Love these! New binge inc
@atheistbro6798
@atheistbro6798 2 жыл бұрын
one of the best class
@mindreader860
@mindreader860 3 жыл бұрын
Excellent Bro ☺♥
@مجهول-ن5ع7ن
@مجهول-ن5ع7ن Жыл бұрын
how i can do random letters ?, like random password
@shebarayan2417
@shebarayan2417 Жыл бұрын
BRO WHY X IN SYSTEM.OUT....
@mibahealthandnutrition4569
@mibahealthandnutrition4569 3 жыл бұрын
If you increase the min value this code give errors. import java.util.Random; public class RandomNumber2 { // If the min > 1 some things is wrong after many turns comes over max limit public static void main(String[] args) { int error = 0; int min = 2; int max = 6; Random random = new Random(); for (int x = 1; x < 1000; x++) { int randomNumber = random.nextInt(max) + min;// Limited the range // double y = random.nextDouble(); // boolean z = random.nextBoolean(); System.out.println(randomNumber); if (randomNumber > max) { System.out.println("ERROR over limit"); error++; } } System.out.println(error + " ERRORS"); } }
@alexanderperez3974
@alexanderperez3974 3 ай бұрын
Best channel ever!
@cweeperyt
@cweeperyt 4 жыл бұрын
Very good Video :)
@BroCodez
@BroCodez 4 жыл бұрын
thanks for watching Creeper!
@Minecarthus
@Minecarthus 3 жыл бұрын
Thank you soooo much !!!
@BroCodez
@BroCodez 3 жыл бұрын
Glad it helped!
@Wolfgirl-bi7ie
@Wolfgirl-bi7ie 2 жыл бұрын
blue jeans and bloody tears
@wassimelshamy4957
@wassimelshamy4957 Жыл бұрын
I love this guy!
@Bawesome1111
@Bawesome1111 4 ай бұрын
Boolean Foolean Toolean Coolean Poolean Woolean
@mustafaismail9802
@mustafaismail9802 2 жыл бұрын
The Random Hypotenuse GUI Form 😁😁😁 import javax.swing.JOptionPane; import java.util.Random; public class Main { public static void main(String[] args) { Random random = new Random(); int a = random.nextInt(20) + 1; JOptionPane.showMessageDialog(null, " a : " + a); int b = random.nextInt(20) + 1; JOptionPane.showMessageDialog(null, " b : " + b); double c = Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2)); JOptionPane.showMessageDialog(null, "The Hypotenuse is : " + c); } }
@garvtech9721
@garvtech9721 3 жыл бұрын
thank u soo much u help me lot
@phiphongnguyen3352
@phiphongnguyen3352 3 жыл бұрын
thank you very much
@jan5504
@jan5504 2 жыл бұрын
where are you now bro code?
@Latestnews124
@Latestnews124 Жыл бұрын
Please I wrote mine on my machine but i have a bug at the point of Int x = random.nextInt(); Thanks
@PetiteKero
@PetiteKero Жыл бұрын
The first "int" needs to be with a small "i". (:
@rufatalizada4006
@rufatalizada4006 3 жыл бұрын
Thanks bro!
@PaulLein-t9m
@PaulLein-t9m Жыл бұрын
Thank you.
@matinmonshizadeh
@matinmonshizadeh 3 жыл бұрын
Thank you bro
@touhidrabbenyshafin8471
@touhidrabbenyshafin8471 3 жыл бұрын
random.nextComment(random comment);
@vidhigill5301
@vidhigill5301 2 жыл бұрын
nice one bro
@alexandregb566
@alexandregb566 Ай бұрын
This is not a random comment.
@armanali9594
@armanali9594 3 жыл бұрын
this code is very useful for me
@aleksandarmilanovic229
@aleksandarmilanovic229 3 жыл бұрын
Great job
@itlogskina
@itlogskina 4 жыл бұрын
Thank you
@biswajeet9826
@biswajeet9826 7 ай бұрын
Good Work Bruh!! Arigato!!
@ibrahimylmaz8378
@ibrahimylmaz8378 2 жыл бұрын
you are amazing!
@JaronDCosta
@JaronDCosta 3 жыл бұрын
what if randomness was random this random thought makes no sense and is therefor a random comment. XD
Java if statements 🚧【6 minutes】
6:12
Bro Code
Рет қаралды 178 М.
My 10 “Clean” Code Principles (Start These Now)
15:12
Conner Ardman
Рет қаралды 314 М.
Sigma Kid Mistake #funny #sigma
00:17
CRAZY GREAPA
Рет қаралды 30 МЛН
It works #beatbox #tiktok
00:34
BeatboxJCOP
Рет қаралды 41 МЛН
小丑教训坏蛋 #小丑 #天使 #shorts
00:49
好人小丑
Рет қаралды 54 МЛН
UFC 310 : Рахмонов VS Мачадо Гэрри
05:00
Setanta Sports UFC
Рет қаралды 1,2 МЛН
Java constructors 👷
10:37
Bro Code
Рет қаралды 203 М.
Using Math.random in Java
5:32
David Dobervich
Рет қаралды 14 М.
Naming Things in Code
7:25
CodeAesthetic
Рет қаралды 2,3 МЛН
Java Math class 📐【6 minutes】
6:12
Bro Code
Рет қаралды 121 М.
Learn Java in 15 Minutes (seriously)
19:50
ForrestKnight
Рет қаралды 168 М.
7 Outside The Box Puzzles
12:16
MindYourDecisions
Рет қаралды 93 М.
Java Program #19 - Generate Random Numbers in Java
6:20
Programming For Beginners
Рет қаралды 25 М.
Array vs. ArrayList in Java Tutorial - What's The Difference?
17:36
Coding with John
Рет қаралды 572 М.
The Flaws of Inheritance
10:01
CodeAesthetic
Рет қаралды 992 М.
How to Learn to Code FAST (Do This or Keep Struggling)
11:00
Andy Sterkowitz
Рет қаралды 723 М.
Sigma Kid Mistake #funny #sigma
00:17
CRAZY GREAPA
Рет қаралды 30 МЛН