Java Programming: 5 - Variable Scope

preview_player
Показать описание
In this tutorial, I explain the basics of scope.

A variable declared outside of any method with the static keyword is called a class variable, and is available to all methods in the class (variables without the static keyword are called instance variables, and will be covered with object-oriented programming in future tutorials).

A variable that is declared inside of a method is local to that method, and only exists until that method is finished executing. It is not directly available to any other methods in the class.
Рекомендации по теме
Комментарии
Автор

You pronounce words so clearly, you leave pauses to let things sink in. Your video was specific to the title. I really appreciate the effort you made. Thank you

leereevebuchanan
Автор

I agree with this. I switched majors, gave up on Computer Science and now I am thinking on minoring in it. Your videos are encouraging me to do it.

You and others on youtube shame both myself and most teachers in the system.

Frazful
Автор

The best Java tutorials I have found on YouTube. Excellent!
Although I wish you would enlarge the editor's font size. Those of us who have poor eyes need large font sizes. 24 pt is a good size for me.

basalduat
Автор

Your videos have already taught me more for java programming than my teacher has Since the beginning of August.

ATCoffey
Автор

All Concepts = Cleared! Thanks a lot for your fantastic efforts. To the point vidoes, no time wasting and you've got a very nice and calm voice too. Keep it up! really helpful videos.

abdur
Автор

That's why so important watch more than one tutorial. I didn't know we can call another method without create a new object. Nice job Charlie.

maxpayne
Автор

Dude, just from your videos I can tell you are a mechanically clean and efficient coder, dont appreciate all the fancy stuff but like crisp smooth running code that looks neat and tidy, lmao cheers mate you have made the life of us Comp Sci undergrads better

lowaiistan
Автор

the only programming video that didnt want to make me kill myself
makes sense and ur a great teacher! :)

rockyk
Автор

Fantastic, Very Clear Tutorial, I will promote to my friends too. :)
Thanks

swaminathavijayaraj
Автор

That's very helpful!
Thank you so much for the video!

emanuelsantos
Автор

Although the voice is not-enthusiastic, thank you for clearing things up!

JMRpink
Автор

Hi
the tutorial look awesome ; is there link to download the source code for each example?

Thanks

liunxnss
Автор

One question here. I see x is printed out only 2 times but I expected 3 times because its being called thrice. Please clarify.

venu
Автор

It is 6:32 long. There may have been a problem with YouTube when you viewed?

CodeMonkeyCharlie
Автор

Lets say you have method, and we know methods start with {
and end with }
If you have a variable inside that curly brackets { int x = 1;}
you can't use that x outside of that method... Curly brackets are the boarder and variable can not be used outside of them, ..
with static variable declared before any method, you can use that variable anywhere inside that class... I hope i got that right and you understood.. :)

ryanrazer
Автор

what is the point of static in variable declaration?

ToTCaMbIu
Автор

why when we write int x without static don't work ?
thanks

abdallahsamer
Автор

Hello, can someone tell me something, if i need to use a field in any other class is there a way to do this ? :)

arberkuci
Автор

static variable:
It is a variable which belongs to the class and not to object(instance).
A static variable can be accessed directly by the class name and doesn’t need any object
Syntax : (class-name).(variable-name)
Meaning you do not have to make an object of a class to use/call it.
It also means you can access that variable form any method, but you have to declare and initialize it before main method like he did. You can't use variables in other methods... continue in next comment

ryanrazer
Автор

At this point someone knows all of my passwords to every site.

audreymciver