This Keyword in Java Full Tutorial - How to Use "this"

  Рет қаралды 136,099

Coding with John

Coding with John

2 жыл бұрын

What does the "this" keyword mean in Java? How and when do you use "this"? We'll cover all of that (and all of "this") in this video.
In Java, the keyword "this" can be confusing for beginners. What does "this" even really mean? How do I know when I have to use it, and what does "this" actually refer to when I do use it?
In this beginner Java tutorial video, we'll give a complete overview of the "this" keyword in Java. By the end of the vide you'll know everything you need to confidently use "this" in your Java programs.
Learn or improve your Java by watching it being coded live!
Hi, I'm John! I'm a Lead Java Software Engineer and I've been in the programming industry for more than a decade. I love sharing what I've learned over the years in a way that's understandable for all levels of Java learners.
Let me know what else you'd like to see!
Links to any stuff in this description are affiliate links, so if you buy a product through those links I may earn a small commission.
📕 THE best book to learn Java, Effective Java by Joshua Bloch
amzn.to/36AfdUu
📕 One of my favorite programming books, Clean Code by Robert Martin
amzn.to/3GTPVhf
🎧 Or get the audio version of Clean Code for FREE here with an Audible free trial
www.audibletrial.com/johnclean...
🖥️Standing desk brand I use for recording (get a code for $30 off through this link!)
bit.ly/3QPNGko
📹Phone I use for recording:
amzn.to/3HepYJu
🎙️Microphone I use (classy, I know):
amzn.to/3AYGdbz
Donate with PayPal (Thank you so much!)
www.paypal.com/donate/?hosted...
☕Complete Java course:
codingwithjohn.thinkific.com/...
codingwithjohn.com

Пікірлер: 185
@lfcbpro
@lfcbpro Жыл бұрын
I've gotta say John, I am doing Java in Uni, and I have their book, and a few others, but your videos wipe the floor with them when it comes to clarity and explanations. Seriously, if you aren't a teacher, you should be one. I was disheartened when I was reading the course materials for my class, but just watching your videos has really helped with everything. Thank you very much indeed.
@JusQuelle
@JusQuelle 2 жыл бұрын
This was a great explanation of the "this" keyword, thank you so much!
@mariap11315
@mariap11315 Жыл бұрын
I've watched a bunch of your videos today just in two hours and I'm amazed of how you make things look so clear in just seven minutes or so per topic :D Great job!
@instayville-is2no
@instayville-is2no 4 ай бұрын
Your explanations have helped me fully wrap my head around these concepts that I have never been able to understand for years in my self-study. Thank you so much! I've subscribed since I'm going all-in on learning Java at this point and I really want to hone in on the basic concepts.
@Clean_Slate
@Clean_Slate Жыл бұрын
You make things look so much easier. I feel like I have watched perhaps an entire lecture after most (if not all) of your videos. And I mean that in the best possible way. Keep being great, you certainly have a gift in teaching!
@koncretemonki8077
@koncretemonki8077 Жыл бұрын
YES!!!
@bhaweshpandey4306
@bhaweshpandey4306 2 жыл бұрын
I am a beginner, so I guess it will take sometime to thoroughly grasp all at once. Thanks for the explanation man!!
@tonyregalado7281
@tonyregalado7281 2 жыл бұрын
probably the best "this" keyword tutorial I've come across... and I've watched a ton. Thanks!
@janelain8611
@janelain8611 2 жыл бұрын
this keyword was so confusing to me as a beginner- more than most other concepts!!-video really nails it down, and helps reinforce my understanding
@tianyiyin4847
@tianyiyin4847 Жыл бұрын
The explanation is insanely clear! Saved me from another course tbh
@gabrielfono844
@gabrielfono844 11 ай бұрын
This is whole different level. I am working hard to get to this point where explaining concept is as easy as coidng with john currently explains thanks for your hard work we all really appreciate.
@user-jq1mp3jc1h
@user-jq1mp3jc1h Ай бұрын
Best explaination on "this" keyword i have ever seen so far on Yt!!! Thanks a lot man🙏🙏🙏🙏🙏🙏
@user-ob8kq6dv6e
@user-ob8kq6dv6e 4 ай бұрын
Your channel single handedly allowed me to pass my intro to java course. Went from failing to a 3.0. Thank you!
@rnages1921
@rnages1921 Жыл бұрын
You explain it better than anyone, bc you inform us what we need to know NOT what you know.
@kevincarter3753
@kevincarter3753 6 ай бұрын
Great tutorials! Right length, right content and great attitude!
@Gandhi_Physique
@Gandhi_Physique 2 жыл бұрын
Wow, I wasn't expecting to learn anything but now I understand it much better. I didn't even know you could call a constructor in that way.
@hammer9185
@hammer9185 Жыл бұрын
I'm just impressed by the way you explain Everything! Excellent job!
@Hassan-lv9di
@Hassan-lv9di 6 ай бұрын
The best explanation i've ever seen !!! thank you alot John! keep up the hard work
@dekumutant
@dekumutant 2 жыл бұрын
Your channel is fantastic. Please don't stop
@abdelkaderkaouane9682
@abdelkaderkaouane9682 2 жыл бұрын
I think that using "this" in class methods, like constructor or getters and setters, is not for avoid confusing between the function parameter and the filed name. The uses of "this" is for referencing the specific object in memory beacause we can have many other objects of the same class.
@prasanthivasu
@prasanthivasu 11 ай бұрын
thank you john. I got my concept clear. was confused in class.
@clementinerose916
@clementinerose916 Жыл бұрын
I am learning java and this helps me a lot , thank you so much John
@user-dc3rj1ty9v
@user-dc3rj1ty9v Жыл бұрын
Really clear explanation, thank you so much!
@gigachard5690
@gigachard5690 Жыл бұрын
Omg been fighting with Intellij to understand getters, setters and constructors and watching This was an instant 4 piece! Thank you!!!
@AeV_artss
@AeV_artss Жыл бұрын
grabe ka na johnny, you really know a lot of work, legend
@jingyiwang5113
@jingyiwang5113 Жыл бұрын
Your explanation of the "this" keyword is crystal clear. After being stuck at this point for such a long time, it finally makes sense to me. I am really grateful for your help! I am in my second year of college and right now, struggling in a java class highlighting algorithms and data structures. I have also checked some of your other videos and will certainly watch more! Thanks!
@darrenfrancis8126
@darrenfrancis8126 Жыл бұрын
im in the same boat but i am building a calculator app and in the tutorial he used "this keyword in a different context. functionButtons[i].addActionListener(this);
@josefiel6842
@josefiel6842 2 жыл бұрын
Great video, the subject is so clearly explained. Amazing explanation, Thanks!!!
@elfentsuki
@elfentsuki Жыл бұрын
Excellent video, very clearly explained, also cool vibe. 10 out of 10. Thank you very much!
@paladarsh39
@paladarsh39 2 жыл бұрын
Great explanation. Addicted to your channel. Thanks for such a simple explanation
@rubinconineski526
@rubinconineski526 10 ай бұрын
It is very good. You speak very good. I understand almost everything 95 %. Thank you.
@ayenoodles9068
@ayenoodles9068 Жыл бұрын
Thank you John! I’m a sophomore Software Engineer, and you explain things much clearer than my professor ✨
@getyournekoshere9824
@getyournekoshere9824 Жыл бұрын
@@jamesdrinkard687 what do you think assignments are in school? also, you think john never went to school? you sound like you're coping a bit.
@Alstash
@Alstash Жыл бұрын
Clear, pleasant, and understandable. Thank you!
@s.a.806
@s.a.806 2 ай бұрын
Very clear, thanks a lot!
@matheuscastroks
@matheuscastroks 5 ай бұрын
your the best teacher ive ever had, thank you
@littlemissmuppet40
@littlemissmuppet40 Жыл бұрын
Far better than the course i've paid good money for :) - Thanks very much!
@isackcosta5660
@isackcosta5660 9 ай бұрын
Good video! Helped me a lot.
@Larfty
@Larfty Жыл бұрын
Thank you so much for teaching this
@YukinoK
@YukinoK Жыл бұрын
You're saving my Java studies. I am really grateful for your classes !
@hikaru_e
@hikaru_e Жыл бұрын
ong, he is crystal clear with what he explains and many times he answers questions I've been wondering about for quite some time
@cshishir4582
@cshishir4582 9 ай бұрын
The tenth grade board exams are comming up and i think that this was a pretty informative video. I really like the efforts put by Sir John who is also teaching us for free unlike most of the cases (tutions example) where they charge tons of money for basic concepts. The plus point is that he is a really great teacher too. Sir i hope that you will continue to do this.
@wallywild5088
@wallywild5088 2 жыл бұрын
Plz keep doing this in just a couple months you’ve provided so much value
@CodingWithJohn
@CodingWithJohn 2 жыл бұрын
Been going for about a year now! But the first bunch of videos were much rougher for sure, so you're probably not wrong that the last couple months had some of the best stuff so far. 🙂
@ColonelloRS
@ColonelloRS 2 жыл бұрын
Very well explained, thank you!
@tellefsolberg5698
@tellefsolberg5698 2 жыл бұрын
Absolutely terrific videos!
@catinsoop
@catinsoop Жыл бұрын
holy crap *this* actually makes sense now! I was trying to do something for a project in my comp sci class and couldn't figure out what I was doing wrong.(also apparently we were supposed to use "this." but it wasn't introduced until the next lesson which was stupid)
@ukrainewarchannel5682
@ukrainewarchannel5682 2 жыл бұрын
Thanks a lot for your videos, they have been a godsend!
@viniciuslima1185
@viniciuslima1185 2 жыл бұрын
your videos are really helpful... much love from brasil!
@jingothejumper
@jingothejumper Жыл бұрын
This is wonderful, I finally understand how this works!
@Roberto-lb5or
@Roberto-lb5or Жыл бұрын
Magnificent explanation as always. I got your bootcamp course at your web page
@_Chad_ThunderCock
@_Chad_ThunderCock 10 ай бұрын
your great teacher. I wish lecturers were half as good as you
@mitmordag
@mitmordag 2 жыл бұрын
Great explanation! Thank you. I am looking forward to next videos
@mk17173n
@mk17173n Жыл бұрын
I see what you did there with the dog named Kramer and the Kramer poster in the back. BTW your explanations are super easy to understand compared to other videos. Amazing work.
@manikandansivakumar4077
@manikandansivakumar4077 2 жыл бұрын
you give answer for every why I ask myself. Thanks
@zehrairkicatal2156
@zehrairkicatal2156 2 жыл бұрын
Perfectly it was explained Looking forward to next your video reference type and primitive type CASTING
@fantasy9960
@fantasy9960 2 жыл бұрын
THank you soooo much! Please continue creating your videos!!
@jerrygord3131
@jerrygord3131 2 жыл бұрын
Thank you so much! This video completely made sense out of it.
@yahyaking3250
@yahyaking3250 Жыл бұрын
Thank you so much, it really helped
@IluSsIoNnN
@IluSsIoNnN 2 жыл бұрын
I am just learning Java (from mechanical engineering, career switch) and your videos are great. Keep it up and Thank you !
@CodingWithJohn
@CodingWithJohn 2 жыл бұрын
Awesome, good luck on the career switch!
@iliasettaoussi4680
@iliasettaoussi4680 2 жыл бұрын
you are an amazing instructor
@cetinarslan262
@cetinarslan262 2 жыл бұрын
Thank you. It was really clear. Good luck...
@jam-yh9il
@jam-yh9il 2 жыл бұрын
Really great videos, thanks!
@gulshanmustafayeva1707
@gulshanmustafayeva1707 6 ай бұрын
You are thee greatest explainer ever 🙂 thank uu
@ceciliaw1065
@ceciliaw1065 Жыл бұрын
Finally understood this, thank u so much
@jer5206
@jer5206 2 жыл бұрын
These vids are gold ty!
@SwarcMaster
@SwarcMaster 2 жыл бұрын
Keep doing great job, John. Thanks to you i can progress Helsinky MooC course like walk in a park.
@CodingWithJohn
@CodingWithJohn 2 жыл бұрын
Awesome! And thanks!
@mckenziepictures
@mckenziepictures 6 ай бұрын
1. This video was AWESOME! 2. Even more awesome, John listens to Rush! (R.I.P. Neil Ellwood Peart)
@lemagamy
@lemagamy Жыл бұрын
great video thank you so much
@meetbohra5415
@meetbohra5415 2 жыл бұрын
Thank-you John!
@lofi_ish5613
@lofi_ish5613 2 жыл бұрын
Thank you so much!
@gunslinger7779
@gunslinger7779 2 жыл бұрын
Thank you so much for THIS video.
@CodingWithJohn
@CodingWithJohn 2 жыл бұрын
I almost added a counter to the video to show every time I said the word "this", I thought it would be hilarious. But then I thought it might have been too distracting. So you all can turn it into a drinking game instead.
@tamingpaola
@tamingpaola 7 ай бұрын
this definitely helped me, im 11 weeks in my java cs class and needed to understand what the hell was going on with these constructors XD
@uritaabdelmasih292
@uritaabdelmasih292 Жыл бұрын
You are amazing! Thanksss
@paulgrossman8830
@paulgrossman8830 11 ай бұрын
John, are you a drummer? Just looking at your kit in the background. Thanks as always for the great videos.
@jvsnyc
@jvsnyc 2 жыл бұрын
Dang near perfect, and no, I don't have any complaint at all, except that in other languages some good developers felt that "this" was redundant in instance methods and should generally be avoided as noise (their approach was non-ideal when the natural name for a method parameter was the same as a data member, of course -- they would wind up having to munge those). On the theme of "I love how you do brief intros that don't overwhelm the learner with minor details without lying or teaching anything they will have to learn later" a very good book I am reading does just that. In a quest to prepare the reader for cert exams, they don't merely ignore stuff that isn't on the exam in that area, but actively make some misstatements that won't affect one's performance on the exam, but if you go beyond later, you will actively have to unlearn some "convenient lies" that they could have just ignored instead. It is a fine line, but you normally always land on the right side of it. There are extremely few "untrue statements" or "non-facts" found in your videos in service of making a good introduction. That is not easy to pull off, and I really appreciate it.
@CodingWithJohn
@CodingWithJohn 2 жыл бұрын
Thanks jvsnyc!
@amiraliazimi6355
@amiraliazimi6355 2 жыл бұрын
Great! ❤️ I always watch your videos
@CodingWithJohn
@CodingWithJohn 2 жыл бұрын
Thanks for watching, glad you enjoy them!
@juliaineslopez4856
@juliaineslopez4856 2 жыл бұрын
I love all your videos! never stop making them!
@IndellableHatesHandles
@IndellableHatesHandles Жыл бұрын
I work in C#, and I swear Java is basically the same language with a different API. I feel like I'll be referring to your videos a lot while working on my CS Java course, though, since Java is different enough to cause some confusion.
@Robert-jt9yg
@Robert-jt9yg 8 ай бұрын
Great stuff
@itsZahid22
@itsZahid22 6 ай бұрын
just helped me thanks
@g33kyt
@g33kyt 2 жыл бұрын
ur a god!!! help me soooo much thank you so much
@abdesamad6616
@abdesamad6616 Жыл бұрын
This was a great explanation of the "this" keyword
@atazky613
@atazky613 2 жыл бұрын
Youre a f*cking magician John, i literally thought about refreshing my java constructor knowledge when you uploaded this video
@CodingWithJohn
@CodingWithJohn 2 жыл бұрын
Thanks! 🧙‍♂️ You may have seen it already, but I have another recent video with even more constructor info here: kzbin.info/www/bejne/ppilnGt-eJydmLc
@zladtv1456
@zladtv1456 6 ай бұрын
Useful!
@dsan6274
@dsan6274 2 жыл бұрын
Thank you again :)
@ousmanetall1286
@ousmanetall1286 5 ай бұрын
My hope is you explain in details the differences between method and constructor, and the purposes
@AshankMishra
@AshankMishra 2 жыл бұрын
Awesome content
@BoonkiCoC14
@BoonkiCoC14 2 жыл бұрын
His videos are so cracked. It's so beginner friendly.
@martineden9888
@martineden9888 Жыл бұрын
Thank you
@Private-lw1td
@Private-lw1td 2 жыл бұрын
Awesome!
@tarikelqari4702
@tarikelqari4702 Жыл бұрын
thank you so much, i was struggling with this "this" hahahahaha
@ujeshnada5141
@ujeshnada5141 Жыл бұрын
this should be the first line in the constructor is the new thing i have learnt.
@Berrybooo
@Berrybooo 6 ай бұрын
Ty so much
@seifashraf2046
@seifashraf2046 Жыл бұрын
I don't know how you make things this simple, suddenly I just understand it and idk how lol
@aminegttabi2994
@aminegttabi2994 2 жыл бұрын
you are the best ❤
@PatrickTouma
@PatrickTouma Жыл бұрын
USE WHAT?!?!?!?!?!
@Bennie.1010
@Bennie.1010 2 ай бұрын
This
@AlyssonTeixeira
@AlyssonTeixeira Ай бұрын
I think he's talking about the drums
@pedroaboffa
@pedroaboffa 2 жыл бұрын
Make a video about creating a server and client with java pls !!!!!!!!! THANK U FOR ALL UR VIDEOS
@ghettoslick2000
@ghettoslick2000 6 ай бұрын
Thanks
@vickyg1877
@vickyg1877 2 жыл бұрын
Bro awesome
@micleh
@micleh 2 жыл бұрын
I'm so annoyed by the fact that here in Germany the government makes pupils use parameters prefixed with a 'p', which is why they'll never get in contact with the 'this' keyword, since there is never a conflict with the field names - I'll tell them, though, anyway. Your Dog constructor would therefore look like 'this': public Dog(String pName, int pAge). I think this is a relict from the time that the default language in higher education was Delphi and senior developers in the government didn't want to give up this parameter naming convention when they had to learn Java. Thanks again for the awesome content. I'll definitely recommend your videos to my students.
@bolbans
@bolbans 2 жыл бұрын
Does this channel have a video about Override?
@user-lj9sq6lr5v
@user-lj9sq6lr5v 7 ай бұрын
Hi john, sorry for my question but I have a doubt. why do you prefer eclipse than Intellij as a IDE? if there are some advantage using one of them, which is you opinion about it ?
@louiemunoz
@louiemunoz 2 жыл бұрын
thanks
@prasadmadusanka4876
@prasadmadusanka4876 2 жыл бұрын
Great video, btw i like your IDE look and feel. Where did you get that?
@CodingWithJohn
@CodingWithJohn 2 жыл бұрын
Thanks! It's the Eclipse IDE, but with a plugin called Darkest Dark installed. Then I actually pick the IntelliJ dark color scheme, just cause I like it best.
@prasadmadusanka4876
@prasadmadusanka4876 2 жыл бұрын
Thanks John. Anyway I want to say this, your videos are clean and clear. Keep up the good work.
Super Keyword in Java Full Tutorial - How to Use "super"
11:33
Coding with John
Рет қаралды 191 М.
Шокирующая Речь Выпускника 😳📽️@CarrolltonTexas
00:43
Глеб Рандалайнен
Рет қаралды 10 МЛН
I Built a Shelter House For myself and Сat🐱📦🏠
00:35
TooTool
Рет қаралды 12 МЛН
Indian sharing by Secret Vlog #shorts
00:13
Secret Vlog
Рет қаралды 57 МЛН
Exception Handling in Java Tutorial
13:20
Coding with John
Рет қаралды 355 М.
Java Main Method Explained - What Does All That Stuff Mean?
7:10
Coding with John
Рет қаралды 217 М.
Java is ALWAYS Pass By Value. Here's Why
5:22
Coding with John
Рет қаралды 116 М.
Static vs Non-Static Variables and Methods In Java - Full Simple Tutorial
11:29
Java Polymorphism Fully Explained In 7 Minutes
7:16
Coding with John
Рет қаралды 288 М.
This Keyword in Java Tutorial #80
10:39
Alex Lee
Рет қаралды 179 М.
Array vs. ArrayList in Java Tutorial - What's The Difference?
17:36
Coding with John
Рет қаралды 488 М.
Java Anonymous Inner Classes Explained in 6 Minutes
6:27
Coding with John
Рет қаралды 91 М.
Map and HashMap in Java - Full Tutorial
10:10
Coding with John
Рет қаралды 531 М.
Big Update in Java for Learners and Trainers
0:59
Telusko
Рет қаралды 288 М.
Шокирующая Речь Выпускника 😳📽️@CarrolltonTexas
00:43
Глеб Рандалайнен
Рет қаралды 10 МЛН