Java variable scope 🌍

  Рет қаралды 53,474

Bro Code

Bro Code

3 жыл бұрын

Java variable scope
#Java #variable #scope
//**********************************************
public class Main {
public static void main(String[] args) {
//local = declared inside a method
// visible only to that method
//global = declared outside a method, but within a class
// visible to all parts of a class
DiceRoller diceRoller = new DiceRoller();
}
}
//**********************************************
import java.util.Random;
public class DiceRoller {
Random random;
int number;
DiceRoller(){
random = new Random();
roll();
}
void roll() {
number = random.nextInt(6)+1;
System.out.println(number);
}
}
//**********************************************

Пікірлер: 93
@BroCodez
@BroCodez 3 жыл бұрын
//********************************************** public class Main { public static void main(String[] args) { //local = declared inside a method // visible only to that method //global = declared outside a method, but within a class // visible to all parts of a class DiceRoller diceRoller = new DiceRoller(); } } //********************************************** import java.util.Random; public class DiceRoller { Random random; int number; DiceRoller(){ random = new Random(); roll(); } void roll() { number = random.nextInt(6)+1; System.out.println(number); } } //**********************************************
@IshmaelDoe
@IshmaelDoe 2 жыл бұрын
hi bro, may I know why you created a constructor that didn't instantiated any value? Is it for the purpose for easy demonstration? In standard practice should we do something like this, and if so what do we us it for? Thank!
@bittertruthnr1
@bittertruthnr1 Жыл бұрын
understood nothing
@kemann3815
@kemann3815 2 жыл бұрын
I study in software engineering major, ive had the program language and advanced program language classes before, which is about the c++ language, and all they taught me was the if statements and the for loops and printing stuff out and taking stuff from the user input. So far ive watched your java course and ive already learned like 10 times more than what they taught me in university. You have no idea how thankful i am for this course. Thanks for real. ❤
@T0ra99
@T0ra99 Жыл бұрын
Interesting, at our University's CS program, variable scope is one of the major content for our first 2 intro courses.
@vocodeex
@vocodeex 5 ай бұрын
how is it possible that a university software engineering couse does not teach variable scope
@z1nai
@z1nai 4 ай бұрын
@@vocodeex you'd be surprised, my university hasn't taught me anything that I haven't already learned in high school. I can learn more in 5 minutes from youtube than what I'd learn in a year on my course.
@vocodeex
@vocodeex 4 ай бұрын
@@z1nai i can do that too but variable scope is important for programming. Its interesting.
@GeoffreyofCastille
@GeoffreyofCastille 2 жыл бұрын
I've learned more from even just your first twenty eight videos in this playlist than I did in the entire semester Java class I just finished taking....thanks! Definitely will be working my way thru your whole series
@AdrianTregoning
@AdrianTregoning 2 жыл бұрын
I've completed the Codecademy Java course, I'm well into a Udemy course too and by watching the first 28 of your videos I've probably learnt more, in possibly less time. One could say it's reinforcement of what I've learnt but I have no doubt I've picked up a huge amount through your videos. Thanks so much for the effort you went to.
@brucedebona6018
@brucedebona6018 Жыл бұрын
A really great aid in learning Java with clear, simple examples illustrating each topic, and an in-depth, engaging presentation by the instructor. One very helpful feature is the code samples accompanying each video. I copy these into Eclipse and play around with making changes and learning from them. For a free "course" in Java, BroCode Java is the best among all others I have tried. I give it an A+. Thank you "Bro".
@bharathpavurala7817
@bharathpavurala7817 2 жыл бұрын
You are a great teacher of all time... 🥰
@user-lk9rf9lk8u
@user-lk9rf9lk8u 7 ай бұрын
thank you so much all of your lessons.
@makankosappo8381
@makankosappo8381 Жыл бұрын
im learning coding by my self thanks to ur videos, thanks a lot. i've accomplished so much in just few weeks and it makes me hope i'll be able to work in this field "soon". u made me fall in love with coding and i cant wait to learn c, c++ and other lenguages. thank you so much for your work and your passion
@john81487
@john81487 Жыл бұрын
Thanks for getting me started on my developer journey
@formlessavatar5220
@formlessavatar5220 2 жыл бұрын
Thanks so much bro. Just wondering if there's actually any difference between the 2 approaches shown (declaring locally and passing as arguments to a method vs. creating global variables that can be accessed anywhere), in terms of memory use and/or any other practical considerations? Are there certain common situations/use-cases I could run into that may warrant using one way over the other, or do we just decide based on individual applications each time? Cheers, much love
@EaglesOps24
@EaglesOps24 Жыл бұрын
IF anyone is confused why he did not assign number in the DiceRoller constructor to 0 its because in java when you intitialize an int it is automatically assigned 0.
@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
@JuliHoffman
@JuliHoffman 2 жыл бұрын
So helpful! Thank you!!
@nicolasarcelin3220
@nicolasarcelin3220 Жыл бұрын
Haven't seen a single one of your videos yet but had to subscribe as soon as I read the username.
@mayankgupta9277
@mayankgupta9277 Жыл бұрын
Java like other language such as C and C++ doesn't have the concept of Local and Global variables as Java is a strictly Object Oriented Language. There are 2 scope defined by Java, one defined by the class and another defined inside the method. P.S - I am not pointing out, I have learnt a great deal from you and love all your videos.
@danny.3036
@danny.3036 3 жыл бұрын
Thanks, Bro! ☕ You're awesome!
@_Anna_Nass_
@_Anna_Nass_ 2 жыл бұрын
Hey you, you are saving my grade. Thanks 🙏
@Nikkhil492
@Nikkhil492 2 жыл бұрын
thank you so much bro. it's very helpful
@paulinewachira5839
@paulinewachira5839 4 ай бұрын
well explained,thank you for sharing
@najmulislam9658
@najmulislam9658 2 жыл бұрын
I like your video Bro.. I am From (Bangladesh)
@bekturasanbekov1979
@bekturasanbekov1979 Жыл бұрын
thx 4 vid bro !
@joshbenjamin1100
@joshbenjamin1100 Жыл бұрын
How can I now use the result of the dice roll? I created a SecondDiceRoller class that extends DiceRoller and only use that object in the Main class (i.e., SecondDiceRoller diceRoller2 = new SecondDiceRoller(); ), giving back two numbers. But what if I want to add those numbers together and use that result to compare against subsequent rolls (if you haven't guessed, I'm trying to make a craps game!).
@unalysuf
@unalysuf Жыл бұрын
I am still watching your videos and I am very glad that I found your channel. I am generally leaving a comment under your videos to support your channel. have a good luck
@ahasanhabibrafy8092
@ahasanhabibrafy8092 2 жыл бұрын
Droping a comment as a prayer to youtube algorithm.
@pushankarmakar1783
@pushankarmakar1783 Жыл бұрын
best playlist on java
@olivezoo
@olivezoo 9 ай бұрын
would be good if these lessons could be named by number...
@mohammadreza1414
@mohammadreza1414 4 ай бұрын
Thanks, bro.
@TheEvertonDias
@TheEvertonDias Жыл бұрын
Thanks, Bro!
@user-zq6yx7of5f
@user-zq6yx7of5f Жыл бұрын
Thank you very much!! Bro
@tonystark6664
@tonystark6664 5 ай бұрын
thank you very much bro
@dllm3tommy741
@dllm3tommy741 7 ай бұрын
Thanks for the video
@Muhammadfaisal-kd9kx
@Muhammadfaisal-kd9kx 7 ай бұрын
thankyou so much
@minhtetpaing1695
@minhtetpaing1695 3 жыл бұрын
Thank you so much sir
@mohamedelfadli3125
@mohamedelfadli3125 Жыл бұрын
I understand the point about the global and local variables, but I need to rewatch the video to gatch the idea of your program. I am not a native speaker like you LOL😜.
@mamunabdullah191
@mamunabdullah191 2 жыл бұрын
thanks a lot bro
@alyymibeal5485
@alyymibeal5485 2 жыл бұрын
Thanks Bro :)
@bobera21000
@bobera21000 Жыл бұрын
you man are a legend
@dalv8749
@dalv8749 11 ай бұрын
ty
@sanjaykumar-uy5jp
@sanjaykumar-uy5jp 3 жыл бұрын
that is Brosome broooo.....
@cesara9747
@cesara9747 2 жыл бұрын
thanks!!
@erniewhite7875
@erniewhite7875 Жыл бұрын
great videos
@matinmonshizadeh
@matinmonshizadeh 2 жыл бұрын
thanks bro
@huuloc8719
@huuloc8719 2 жыл бұрын
NIce.
@adityaalshi7081
@adityaalshi7081 2 жыл бұрын
great🙌
@saidsallah7643
@saidsallah7643 7 ай бұрын
nice video loved it
@ardcodelover
@ardcodelover Жыл бұрын
Liked
@msmisra1976
@msmisra1976 2 жыл бұрын
thank you sir
@nikitassouvatzis1928
@nikitassouvatzis1928 Жыл бұрын
Ένα ακόμα σημαντικό θέμα για την εκμάθηση της γλώσσας Java, είναι η εμβέλεια (scope) των μεταβλητών (variables).
@maziarheidari9797
@maziarheidari9797 Жыл бұрын
Thanks
@javierpesaresi311
@javierpesaresi311 Жыл бұрын
Capo!!!
@developerjunior446
@developerjunior446 3 жыл бұрын
👍
@PoorwayTraning
@PoorwayTraning Жыл бұрын
thanks
@baubaudinamo
@baubaudinamo 3 жыл бұрын
nice
@percivalgebashe4376
@percivalgebashe4376 Жыл бұрын
Nice
@danielmilewski7659
@danielmilewski7659 Жыл бұрын
awesome course! comment for stats.
@lulupapaya3504
@lulupapaya3504 Жыл бұрын
my bro
@pa-305
@pa-305 2 жыл бұрын
best brio
@meggieelo
@meggieelo 2 жыл бұрын
@greeneggsandmushrooms9855
@greeneggsandmushrooms9855 3 жыл бұрын
360 bro scope
@lamias7712
@lamias7712 2 жыл бұрын
Done
@Mustaux
@Mustaux 2 жыл бұрын
defeat the algorithm!
@omersond4891
@omersond4891 3 жыл бұрын
like
@alexyakoveno4682
@alexyakoveno4682 Жыл бұрын
@Simis999
@Simis999 Жыл бұрын
When I subscribe I become local
@ethanalkout949
@ethanalkout949 3 жыл бұрын
Still a confusing topic to me but what ever
@TWVVermin
@TWVVermin 2 жыл бұрын
almost forgot thank you
@efril802
@efril802 2 жыл бұрын
lets defeat the algorithm
@wallstreetbets7741
@wallstreetbets7741 Жыл бұрын
learm
@NileshYadav-rg8bf
@NileshYadav-rg8bf 3 жыл бұрын
I am getting an error that symbol not found on the code: DiceRoller diceRoller = new DiceRoller(); Help me out.
@abisarwan20
@abisarwan20 3 жыл бұрын
u have to create new fille as class with name DiceRoller
@venkatasrikarkavuri2089
@venkatasrikarkavuri2089 Жыл бұрын
You don't get them girls loose, loose You don't get the world loose, loose You don't get money, move, move But I do, I do I said, y'all having a good time out there? Yeah, yeah, yeah, que no pare la fiesta Don't stop the party
@muhammadmushfiqurrahman1653
@muhammadmushfiqurrahman1653 2 жыл бұрын
Hey bro, please verify your channel to brave creator so I can give you some tip.
@adityalochan5482
@adityalochan5482 Жыл бұрын
Have you tasted Bro Code
@hegelbacor7624
@hegelbacor7624 Жыл бұрын
Hi Sir Can ask a copy of code for all project? Thank you in advance.
@shalty554
@shalty554 10 ай бұрын
it is already in the video's decription
@eugenezuev7349
@eugenezuev7349 Ай бұрын
@AARTIKUMARI-fe8wx
@AARTIKUMARI-fe8wx Жыл бұрын
vedio 27
@maciejkaminski8535
@maciejkaminski8535 2 жыл бұрын
comment
@ibrahimylmaz8378
@ibrahimylmaz8378 2 жыл бұрын
thanks bro
@MrLoser-ks2xn
@MrLoser-ks2xn 2 жыл бұрын
Thanks
@johan-oe9kz
@johan-oe9kz 2 жыл бұрын
👍
@salvadego7834
@salvadego7834 Жыл бұрын
nice
@yeliza2350
@yeliza2350 2 жыл бұрын
@anjapietralla5767
@anjapietralla5767 4 ай бұрын
@salvadego7834
@salvadego7834 Жыл бұрын
nice
Java overloaded constructors 🍕
8:02
Bro Code
Рет қаралды 64 М.
Premature Optimization
12:39
CodeAesthetic
Рет қаралды 751 М.
The most impenetrable game in the world🐶?
00:13
LOL
Рет қаралды 33 МЛН
La final estuvo difícil
00:34
Juan De Dios Pantoja
Рет қаралды 27 МЛН
Java objects (OOP) ☕
10:46
Bro Code
Рет қаралды 149 М.
Primitives Data Types In Java - All the Primitives And What They Do
10:24
Java constructors 👷
10:37
Bro Code
Рет қаралды 162 М.
Java Scope - Scope of Variables in Java Tutorial #53
9:57
Alex Lee
Рет қаралды 21 М.
Lambda Expressions in Java - Full Simple Tutorial
13:05
Coding with John
Рет қаралды 695 М.
Scope and Local Variables in Java
9:41
Neso Academy
Рет қаралды 81 М.
Java methods 📞
11:05
Bro Code
Рет қаралды 117 М.
Java Strings are Immutable - Here's What That Actually Means
7:06
Coding with John
Рет қаралды 601 М.
Трагичная История Девушки 😱🔥
0:58
Смотри Под Чаёк
Рет қаралды 375 М.
Куда пропал 3D Touch? #apple #iphone
0:51
Не шарю!
Рет қаралды 547 М.
Выложил СВОЙ АЙФОН НА АВИТО #shorts
0:42
Дмитрий Левандовский
Рет қаралды 1 МЛН
5 НЕЛЕГАЛЬНЫХ гаджетов, за которые вас посадят
0:59
Кибер Андерсон
Рет қаралды 257 М.