Global Variable In Java - How To Use Global Variables In Java

preview_player
Показать описание

Here's how to use global variables in java.

Global variables go at the top of your class and are usually used for hardcoded values.

Global variables in java can be tricky at first... But SURELY you'll get it :) If you followed along, congrats! You learned global variables by-doing!

I hope you enjoyed this java global variable tutorial! I like to have a nice mix of java tutorials and actual projects for you all :)

Was this able to help you learn global variables in java?

Disclosure: The Springboard link provided is linked to my affiliate account & supports the channel.

Alex Lee
Рекомендации по теме
Комментарии
Автор

God bless u man u wont believe the number of videos i have had to watch just trying to get the hang of global variables and u just laid it out for me in less that 5mins tnx

joshuacobbinah
Автор

I came from your Static Keyword video to watch this. These videos are great at making seemingly complex topics appear simple and easy. Keep up the great work.

victoryb.
Автор

Thanks so much, dude. You save me 7 years with that one keyword








static

izzathazmi
Автор

We'll explained. Learned something new. Although, when the video started, I was like music? Oh no please no, then it faded out. Exhale. :) Keep up the good work. SuperB.

maxd
Автор

You should be an instructor. I have learned so much from you and will continue to learn from you. Thanks

jamesnolan
Автор

Bro ur a life saver, I'm just now getting into computer science and sometimes I'll forget certain functions of things

iordanus
Автор

You're the man! Great teaching skills! You motivated me to continue my java project even tough my profession is something totally different, and i have 0 skills in programming. Greetings from Croatia! :))))

KristoLaptalo
Автор

Dudeee tysm again!
Youre awesome Alex!

av
Автор

Thank you Alex. You're always amazing

aabdille
Автор

how to we change global variables and make them available for some function that are outside this class ?

codeRush
Автор

✨Global variables eat more memory but save processing of your code.
🍀Local variable save memory but add extra processing of your code.

Choose which you need more.

Кукусик-еэ
Автор

sorry it was too quick~ {"Jan", "Feb", "Mar", : ---> what did you do to make the rest display?

dragonsea
Автор

Iunno, hard coding seems easier to me. Using a global variable, you always have to remind yourself/scroll back up to the top to check what value you’re actually working with.

saveUyghurs
Автор

I was wondering why my code wasn't working. I needed to put static. THANKS :)

jobbaffet
Автор

🔥Be cautious in using static variables!
Static means it belongs to Class itself, not to instance of that Class.
If you create two or more instances of a class, static variables will be administered by all your instances dependently. If you use something like "static int age" in class Person, then all objects of that class will have same age at all times.
Do not use static if you're not sure you really need that.

Кукусик-еэ
Автор

I think I only use global variables then, but sometimes still run into the issue that a method cannot change it (or changes it, but the change does not stick). Puzzling.

DiaborMagics
Автор

hi Alex ! your you help me in a java assignment

Yuuki-xtxs
Автор

What? Those are NOT global variables?!?
There's nothing 'global' about them, because they're still scoped to the class.

welltypedwitch
Автор

you are a criminal just for mentioning this...

lapepitadeorooficial