No video

Access Modifiers Java Tutorial #82

  Рет қаралды 230,276

Alex Lee

Alex Lee

Күн бұрын

$1,000 OFF ANY Springboard Tech Bootcamps with my code ALEXLEE. See if you qualify for the JOB GUARANTEE! 👉 bit.ly/3HX970h
The access modifiers Java has are default, public, private and protected. These let you say which files can see methods and variables. ✅Hopefully, this java access modifiers tutorial taught you will help you fix your null pointer exception.
👑Start practicing now with 10 free java programs - alexlorenlee.com/
Java access modifiers can be tricky at first... But SURELY you'll get it :) If you followed along, congrats! You learned-by-doing!
I hope you enjoyed this access modifiers java tutorial! I like to have a nice mix of tutorials and actual projects for you all :)
Do you want to learn how to write java code from scratch, in Java? Check out my Java Tutorial For Beginners: • Coding For Beginners I...
Was this able to help you learn about default, public, private and protected in java? -
Full Java Tutorial For Beginners Playlist: • Full Java Course by Al...
Free Tips: bit.ly/3U6HXcb
Disclosure: The Springboard link provided is linked to my affiliate account & supports the channel.
~
Alex Lee

Пікірлер: 233
@alexlorenlee
@alexlorenlee 10 ай бұрын
If you’re new to programming but want a career in tech, I HIGHLY RECOMMEND applying to one of Springboard’s online coding bootcamps (use code ALEXLEE for $1,000 off): bit.ly/3HX970h
@haaaaadsfggh
@haaaaadsfggh 4 жыл бұрын
Summary: 1. private: accessible in the same file 2. default: accessible in the same package 3. protected: accessible in the same package; accessible in all packages w/ "extend" E.g. otherpackage extend package1{ 4. public: accessible in all packages
@ERica-ee9ik
@ERica-ee9ik 4 жыл бұрын
Thank you. I enjoy Alex's videos. He is a pro!
@rapportapp8852
@rapportapp8852 4 жыл бұрын
Isn't public only accessible in the same CLASS?? and not the file?
@jscorpio1987
@jscorpio1987 4 жыл бұрын
Rapport App you mean private?
@bariswheel
@bariswheel 3 жыл бұрын
What pain points do these address. Why do they matter?
@jscorpio1987
@jscorpio1987 3 жыл бұрын
@@bariswheel pain points?
@romanparra7639
@romanparra7639 5 жыл бұрын
Hey, I live in Mexico and I'm self-studying Java for computer science AP. I just wanted to let you know that even though you have a small channel, you already have international viewers. Vary the channel content a little, post a bit more often, and I'm sure you'll gain a bigger following. You have quality videos and lots of potential. Keep up the good work! :)
@bubboydarker9030
@bubboydarker9030 4 жыл бұрын
Hey, I live in the streets
@theillusionist9506
@theillusionist9506 3 жыл бұрын
I live in India
@keshinrotobi9725
@keshinrotobi9725 3 жыл бұрын
i live in Austria
@A-M-A-N-G
@A-M-A-N-G 3 жыл бұрын
Go through some Indian java tutorial playlists, you will get some better insights. Eg. Neso academy
@romanparra7639
@romanparra7639 3 жыл бұрын
@@A-M-A-N-G I mean, right now I was able to get into the college of my choice here in the U.S. So I'm a little occupied with that.
@rajkush319
@rajkush319 4 жыл бұрын
Your way of teaching is just exceptional
@sreekarkambam5619
@sreekarkambam5619 3 жыл бұрын
yeah, I didn't feel it like a boring lecture. it's too simple and easy to know and learn just by watching
@LeGrandeux
@LeGrandeux 5 жыл бұрын
You helped me with my programming exam last semester. Thank you.
@alexlorenlee
@alexlorenlee 5 жыл бұрын
C Cachuela no problem!
@ziyaadmoosa3643
@ziyaadmoosa3643 4 жыл бұрын
Public variables/methods can be accessed from any class or package. Default variables/methods can only be accessed from within the same class or within the same package - a default variable/method cannot be accessed from a class in a different package.
@hyphen8d725
@hyphen8d725 4 жыл бұрын
So default is basically the same as protected, right?
@waschbar4960
@waschbar4960 4 жыл бұрын
@@hyphen8d725 No unfortunately it's not. With default you can only access within the same package but a protected variable/method can be accessed through inheritance (keyword extends) even from different packages. That's the only difference :)
@hyphen8d725
@hyphen8d725 4 жыл бұрын
@@waschbar4960 oh, I see, thank you!
@AdamAdam-le3pm
@AdamAdam-le3pm 2 жыл бұрын
it seems like every time i have a question, you show up with the answer. Count me subscribed!
@bnug242
@bnug242 5 жыл бұрын
Just wanna let you know that your vids help me out the most when learning java. Thanks!!!
@diclebahceli622
@diclebahceli622 4 жыл бұрын
I've already watched people from my country for this topic. But I didn't understand them as much as you. Thank you so much, you helped me a lot. :)
@Abyasun
@Abyasun 4 жыл бұрын
Alex, I watched a lot of videos on Java. Frankly speaking, you are doing a great job. Thank you for your time and your praise-worthy efforts! Kind Regards.
@serafall7326
@serafall7326 Жыл бұрын
I just wanted to thank you for your videos, but honestly...thank you. Words can barely describe how much it helped me starting to learn programming. Your videos are so easy to understand and its short and timesaving. If i learned everything from books, it would have taken me tens or hundreds of hours more!
@abdeselamselami4532
@abdeselamselami4532 4 жыл бұрын
Thanks a lot Alex, for everyone the short-cut of System.out.println is type sysout + hit buttons ctrl+space.
@anaralizada8884
@anaralizada8884 2 жыл бұрын
Amazing youngest teacher, Amazing personality. I appreciate it bro. Respect you a lot from Azerbaijan.
@sararogers1548
@sararogers1548 4 жыл бұрын
Thank you for posting this tutorial! I watched other videos of people trying to explain it and it made 0 sense. You really broke it down simplistically. I appreciate it!
@vensenpai7769
@vensenpai7769 2 жыл бұрын
this video was sent by my teacher in our google classroom and I think this is great.
@sachinjaveri1
@sachinjaveri1 3 жыл бұрын
This is the most clear explanation that I saw till date. Thank you very much Alex.
@rajtonystark6082
@rajtonystark6082 10 ай бұрын
You are the best Java tutor who put the idea of Java is not at all hard to learn❤❤
@sitinorfarhana5510
@sitinorfarhana5510 3 жыл бұрын
You are life saver! my lecturer just gave us the coding and asked us to run the coding to understand on our own :O
@ruthvikls
@ruthvikls 2 жыл бұрын
wow man, been searching whole youtube about this from past 2 hrs! i finally got it Thank you so much
@sathya8425
@sathya8425 9 ай бұрын
U made the video in a very simple way to understand. Thanks a lot
@SazidShan
@SazidShan 4 жыл бұрын
love how simply you convey the concepts and often giving real life examples. I know programming concepts can be implemented to any languages, but would love to see some videos with C as well. thanks for the videos man, helped me a lot. all the best, stay safe, stay healthy and happy.
@sandeeppandey191
@sandeeppandey191 3 жыл бұрын
"So the only difference between default and public is that public you write it in front" - that's not correct. Default fields are only visible to classes in the same package while Public fields are visible to any other class If you leave the access modifier for hours and minutes as 'default' in the class 'Access1', you won't be able to access those fields in the class 'Access3', which is in another package.
@Jakeryanu
@Jakeryanu 3 жыл бұрын
He says it at the end
@horsepower33
@horsepower33 3 жыл бұрын
@@Jakeryanu I missed it, so thank you for this. Had to go back.
@cocosaurus3893
@cocosaurus3893 3 жыл бұрын
Yeah, I figured this one out when I tried using the variables in a different package.
@hernandezmartinezfamily8005
@hernandezmartinezfamily8005 3 жыл бұрын
Where is your channel?
@salmaamer2497
@salmaamer2497 Жыл бұрын
after 4 videos and 12 lectures I finally get it thank u
@valianenriquez4645
@valianenriquez4645 2 жыл бұрын
learning basic java again , thanks for making all your videos feel like we're watching blue's clues, you made java look simple.
@robinsuper2
@robinsuper2 6 ай бұрын
😁Thanks, your videos have been helpful beyond measure!!!
@user-xh5eo8ip7h
@user-xh5eo8ip7h Жыл бұрын
Very nicely explained, thank you. I am also glad that you are not using dark mode like others. So much easier to see when it is white background 🙂
@tusharsuthar3
@tusharsuthar3 4 жыл бұрын
Hey Alex, Your Videos are really fruitful. Its helping a lot.
@isuryakant9921
@isuryakant9921 4 ай бұрын
Allover.⬇️ 1. Default. Access within the package only. 2. Public. Access everywhere even outside the package . 3. Private. Access Only in class . 4. Protected. Access in 1 package only but if you use extends keyword then it access in outside the package. But there outside the package Object must be that 2nd package's class
@jakefenwick-scott1726
@jakefenwick-scott1726 3 жыл бұрын
You are amazing bro! I am currently doing a full stack developer internship with no prior knowledge you are saving me!
@maryozonkwor-ei8vw
@maryozonkwor-ei8vw Ай бұрын
Thank you. Very concise and easy to understanding 🎉🎉🎉
@Jake1702
@Jake1702 4 жыл бұрын
Huh this was simpler to understand than I expected.
@premkumarjegatheesan5687
@premkumarjegatheesan5687 4 жыл бұрын
Thanks Alex... Its very helpful to understand in a simple way..keep it up...
@user-jh2qf4oz9n
@user-jh2qf4oz9n 2 жыл бұрын
I really like your tutorials🥺really help me alot, any topic i was confused I would just search like "interface in java Alex "!!!
@alexgieder9107
@alexgieder9107 4 жыл бұрын
You videos are the reason I am passing my Java class, these videos are clean, easy and your voice recording is amazing. Thanks for creating these videos. Means so much
@fiona2678
@fiona2678 3 жыл бұрын
I was struggling with this topic. Finally this video helped me. Thanks a lot.
@muhammedishal9559
@muhammedishal9559 2 жыл бұрын
Great video i ever seen on Access Specifiers. You clarified my entire doubts.
@DavidMVFX
@DavidMVFX 3 жыл бұрын
incredible explanation, very clear and focused. thank you alex!
@CaitlinB0000
@CaitlinB0000 4 жыл бұрын
This was a great intro video to class modifiers. I am starting to understand some of the words I have been blindly typing into my programs. I’d love to see a video with some examples of when these different modifiers are useful.
@mridulyadav1680
@mridulyadav1680 2 жыл бұрын
Hi Alex , Awesome tutorial, it helps me lot ..love ❤️ from 🇮🇳
@zainabomar1283
@zainabomar1283 2 жыл бұрын
Thanks, really appreciate your work! all the way from Saudi...
@shakouramohaghegh2786
@shakouramohaghegh2786 2 жыл бұрын
Your explanation was SUPER clear . Thanks a lot
@MdFoysal-zj6jm
@MdFoysal-zj6jm 3 жыл бұрын
Thanks man...You make it easy to understand... In the protected class exends part was confusing but at last i read it drom Quora Thanks a lot man... Many Many thanks
@APersonOnTheWeb
@APersonOnTheWeb 5 жыл бұрын
Hi! From India! I like you videos!
@spongewent1479
@spongewent1479 3 жыл бұрын
default is only at the same package (not subclasses that are out of the package) hierarchy: private -----> default -----> protected -----> public
@theBATfamiliar
@theBATfamiliar 3 жыл бұрын
Hi Alex, I'm learning Java and I find your videos very educational and enjoyable, I just subscribed, thanks a lot for sharing :)
@nikolai1790
@nikolai1790 3 жыл бұрын
This was very helpful. Explained so plainly thank you!
@kqvanity
@kqvanity Жыл бұрын
7:15 Funny how it's usually stated that protected is always confined to a its class/its subclass (irrespective of being of the same package or not)
@jamiefeder9617
@jamiefeder9617 3 жыл бұрын
Alex you make coding fun! Please keep on
@saswataroy1699
@saswataroy1699 4 жыл бұрын
Hey Alex you make amazing tutorials I cleared many doubts by watching your tutorials.But I am facing to much problem in array can you make more tutorial on that topic.....
@Dumsboo
@Dumsboo 4 жыл бұрын
You are a really helpful Java tutor
@sindhumuddana6785
@sindhumuddana6785 3 жыл бұрын
Hiiii Alex, Tq for your valuable videos. it is really informative to the one who want to learn Java from basics.
@athirajyothishkumar6933
@athirajyothishkumar6933 2 жыл бұрын
Very concise and easy to understand. Thank you
@user-tt2th6hp8r
@user-tt2th6hp8r 3 жыл бұрын
thank you so much Alex, i appreciate you
@هُدى-رياض
@هُدى-رياض 2 жыл бұрын
رائع لقد اجبت بالامتحان بفضلك شكرا لك ❤
@andrei-adrianhogea4049
@andrei-adrianhogea4049 4 жыл бұрын
Hi there! Can you please explain the non-access modifiers as well? Great job so far.
@criblaj
@criblaj 4 жыл бұрын
So your are saying at some point(10:20) that default is like public, some other times mentioning that default is accessible just within the same package ...
@karthickparthiban6633
@karthickparthiban6633 4 жыл бұрын
Thanq for explaining us in simplest way and it makes me more interested to learning java 😍 tq 1ce more
@maxiomatic1609
@maxiomatic1609 2 жыл бұрын
thank you, bro! you should also make a JavaScript and/or Python course!
@mansimakwana868
@mansimakwana868 4 жыл бұрын
What an explanation!🤩 Thanks a lot!
@aniket6482
@aniket6482 3 жыл бұрын
Thank bro made this content on access modifier
@mauamadoudrammeh8083
@mauamadoudrammeh8083 3 жыл бұрын
thank you. you are great. have a great day
@raghuveer806
@raghuveer806 3 жыл бұрын
Superb dude..I like the way of teaching 🙏
@pp-ij6yn
@pp-ij6yn 2 жыл бұрын
Hi there, why is void sometimes used by itself with no access modifiers for e.g. - void fillup(); (which you used in your other video for water bottle) THANK YOU.
@Aaru6384
@Aaru6384 3 жыл бұрын
Thanks. Helped a lot.
@dicedip7431
@dicedip7431 5 жыл бұрын
Hey Alex! These tutorials are great! Do you know if you'll be making any game development projects too?
@alexlorenlee
@alexlorenlee 5 жыл бұрын
dice dip hi and thank you! I don’t really know anything about game development so I wouldn’t want to misinform anybody on a topic I don’t know, but I do know java! So I’ll be sticking to java for now :)
@dicedip7431
@dicedip7431 5 жыл бұрын
@@alexlorenlee Aye no problem!!! Your tutorials are he best I've seen! I've searched the internet for DAYS trying to at least find a program to code in before I saw you! Thank you so much for everything!
@EmadElSherif
@EmadElSherif 2 жыл бұрын
Man you are Legend!!!!
@AhmedAli-dz1hy
@AhmedAli-dz1hy 4 жыл бұрын
Best of the best.very easy to understand
@kalyanchatterjee8003
@kalyanchatterjee8003 4 жыл бұрын
Super helpful! Thanks Alex
@anisingh1598
@anisingh1598 3 жыл бұрын
A video with examples. Yay!
@juliandave3648
@juliandave3648 2 жыл бұрын
what are the main benefits of such seperations between classes?
@fungus4898
@fungus4898 3 жыл бұрын
hey I am from India and use Bluej to study Java, your videos are a great help and i have recommended it to my friends. In Bluej when i use Ctrl-space the triangle or the dot things do not appear and they all are the same. Thanks.
@eien7228
@eien7228 5 жыл бұрын
Thx for explaining its help alot but i see u havent change println a to b at 8.22
@alexlorenlee
@alexlorenlee 5 жыл бұрын
oops! That should've been b, my bad :)
@mohamedkanu66
@mohamedkanu66 3 жыл бұрын
So protected and default kind of work the same way ? Your ending statement kind of conflict the starting where u said default works like public . Please can someone clarify ? Thanks
@poonamkachari1061
@poonamkachari1061 3 жыл бұрын
GOOD TEACHER......KIP IT UP
@fahyen6557
@fahyen6557 3 жыл бұрын
but why public static method cannot be run another file of the same package?
@usmaan9118
@usmaan9118 2 жыл бұрын
Hey Alex you make amazing tutorials I cleared many doubts by watching your tutorials.But I am facing to much problem in array can you make more tutorial on that topi
@biophilic23
@biophilic23 3 жыл бұрын
Thank you so much for this. Your are AMAZING!!!
@linhtranbao4732
@linhtranbao4732 2 жыл бұрын
I understood thank you very much
@kavindus
@kavindus Жыл бұрын
You are very kind. Thank you!
@ChrissPBacon-mo4hy
@ChrissPBacon-mo4hy 4 жыл бұрын
I always downvote your videos so I can upvote it two times.
@arduinomistakes8879
@arduinomistakes8879 Жыл бұрын
Would be useful to add "static" and also show effect on instantiations of the classes Access 1, Access2, Access 3.
@Mehedimasud-uy5nx
@Mehedimasud-uy5nx Жыл бұрын
thanks dude..love from bangladesh
@hajouighezlene8938
@hajouighezlene8938 3 жыл бұрын
I did exactly what you did and when i access the variable into an other class i get the value null.
@johnymadrita9065
@johnymadrita9065 Жыл бұрын
What is the difference between public and published?
@joethompson8147
@joethompson8147 4 жыл бұрын
very helpful Alex!
@minaamir2648
@minaamir2648 3 жыл бұрын
why we need two main classes ? is this only for explainnation or used in real word projects ?
@gutenmorgan2063
@gutenmorgan2063 3 жыл бұрын
I am just making sure but for private classes, we can get them to access public classes by doing returns, correct?
@lopez10897
@lopez10897 3 жыл бұрын
is there a way to get private method info from a public class into another public class? For example I have a public class with a private method that calculates distance. I have to make test cases. How could I call to that class / method to test that it works?
@roniacharjee7269
@roniacharjee7269 3 жыл бұрын
From Bangladesh .. I like your video
@elatreby8065
@elatreby8065 3 жыл бұрын
That was a great vid man. well done you are LEGEND
@talgreen7451
@talgreen7451 2 жыл бұрын
Maybe worth mentioning the assignment issues with different access modifiers. E.g at 'protected', you can assign a different value to a variable inside the same package, but while on a extended class - you cant change the value of the original class's variables. I know I explain terrible, maybe Alex can do it better :))
@reichelleremo9969
@reichelleremo9969 4 жыл бұрын
is there a video of how to access the array of object to the main method? p.s. i enjoy watching your tutorial . it is a good help to a person like me as a student.
@revolutionoftheresolution5867
@revolutionoftheresolution5867 4 жыл бұрын
we can access protected variables or methods using constructor also.
@SomeOne-rx2xw
@SomeOne-rx2xw 2 жыл бұрын
Best teacher!
@AGI-001
@AGI-001 3 жыл бұрын
New subscriber here❤️.. Love your explanation!!!
@jonahpadberg3485
@jonahpadberg3485 Жыл бұрын
super helpful thank you
@sushilsingh4237
@sushilsingh4237 4 жыл бұрын
you teach really very good i hope so,you will gain a big no. of followers very soon
@abhachhabra2762
@abhachhabra2762 4 жыл бұрын
Hello Alex, nice videos about Java.Can you post something about POM in selenium
@god_of_the_gods7
@god_of_the_gods7 3 жыл бұрын
I think that you should put most of the videos of this playlist after you talk about oop because you create objects to access classes but havent explained it yet. Anyway good work bud.
@ericamuhammad5082
@ericamuhammad5082 2 жыл бұрын
Thank you!
Encapsulation in Java Tutorial #83
11:06
Alex Lee
Рет қаралды 254 М.
Java access modifiers: (public, protected, private) 🔒
10:13
Nurse's Mission: Bringing Joy to Young Lives #shorts
00:17
Fabiosa Stories
Рет қаралды 3,3 МЛН
The Joker kisses Harley Quinn underwater!#Harley Quinn #joker
00:49
Harley Quinn with the Joker
Рет қаралды 14 МЛН
Abstract Class In Java Tutorial #79
8:55
Alex Lee
Рет қаралды 539 М.
Exception Handling in Java Tutorial
13:20
Coding with John
Рет қаралды 380 М.
Main Method In Java Tutorial #57
9:50
Alex Lee
Рет қаралды 120 М.
Learn Java in 14 Minutes (seriously)
14:00
Alex Lee
Рет қаралды 4,7 МЛН
Getters and Setters Java Tutorial #84
14:12
Alex Lee
Рет қаралды 495 М.
Writing My Own Database From Scratch
42:00
Tony Saro
Рет қаралды 212 М.
Learn JSON in 10 Minutes
12:00
Web Dev Simplified
Рет қаралды 3,2 МЛН
Coding Will Never Be The Same | Cursor + Claude 3.5 sonnet
18:54
Tech Overseas
Рет қаралды 17 М.