Java Programming Tutorial 3 - Understanding Java Foundation

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
welcome back everybody this is your third video over Java programming my name is Caleb and thank you guys for watching this video my goal is to help you understand all this stuff and this is honestly probably where most people quit so congratulations on being better than like 95% of the people that watch these videos before we get started though I did want to give a special shout out and thank you to our sponsor pram pram is a peer-to-peer interviewing system you can use their service to practice your java skills and practice data structures and algorithms but also things like behavioral interviews system design front-end development data science and more pram is totally free and when you use this service you get paired with other individuals so not only do you get interviewed but you also get to get that experience interviewing other people and seeing where some of the most common downfalls are so if you want to improve your java and your computer science skills go check out pram especially if you're hoping to get a job in the industry cuz people are using pram to get offers from Amazon Google Twitter and more so I'll leave a link for you guys in the description all right now to covering all of this crap so if you're new to Java development you can kind of ignore everything above this line and everything below this line and just kind of put your code here in the middle and a lot of beginners do that but you guys know that my principle here is that I want to hope you guys understand why we're doing things and how it's working rather than just what to type so I'm not going to ignore this stuff so before you start learning what all these terms mean I just recommend you go in here and start changing things and see how it affects your program now my goal is to help you guys understand everything here but one thing I wanted to tell you guys is that at some point you're going to exit as something important and you're gonna be annoyed because you're not gonna know how to get it back that happens to me all the time so if that's the case what you need to do is you need to go up here to the top and go to window perspective reset perspective and that's just gonna get everything from the the fresh start that we had at the very beginning so now we can go and open our code again so now that you know how to protect yourself in the case of failure let's get started the first thing that you need to know is that everything is inside of a class and each class has a name we named it my sweet program inside of classes we have what are known as methods so this is an example of a mess just like a class has a name my sweet program well all of your methods are going to have a name as well and in this case our method is called main the technical name for this right here is an identifier so our class has an identifier and our method has an identifier inside of our method we execute statements so this is an example of a statement and throughout this series you're going to learn all kinds of different statements so it's kind of like this nesting doll the biggest thing here is the class and then inside of the class we can have a method and then inside of the method we can have a statements another thing you should know is that this method is an example of a member so every single thing that's part of this class my suite program is known as a member so you can say that the contents are the the members of this class we could go in here and add more members so for example and if you don't understand all the syntax that's cool don't worry here we are creating a new member so now we have two members we have a method which is called main and then we have a string which is called X and this string is an example of a property by the way so we have methods and then we have properties methods usually do something so in this case it's printing to the console properties just store some value for example I could store the value hello and just to run this make sure I don't got any issues yeah it's still working so you can see this nesting concept in our code so for example for this statement right here we have this system class and then inside of the system class we can access its members using this dot and one of those members is called out and out has a member print line which is a method so you can see how we just have to understand that the structure consists of classes which contain members and as members can be properties or methods alright so now I'm just gonna get rid of this and kind of go back to how we had it at the beginning okay so what about this public stuff well these are known as access modifiers and there's some different options so for example we could put private which that's actually not gonna work so we get an error when we make it private because every single executable Java program needs to have a public method called main but just so you know for future development we can change this access modifier to different things and basically this determines who can access this method or who can access this class in this case because this class is public so when we have a really complex java application we're gonna have multiple classes and these classes will interact with one another and you can control that access by using these different access modifiers such as public or private and so forth another thing you guys should understand is the use of these curly braces when are we supposed to use curly braces and eclipse is kind of cool because if you click one of these curly braces it's going to make a box around the the matching closing curly brace so you can kind of think of it if I just got rid of all this here is our class structure and then everything inside of these curly braces is part of this class then we do a similar thing inside of here with the method and everything inside of this curly brace in this curly brace is part of that method and just by convention we indent everything that's inside of curly braces and when I say convention I just mean that it's very very common everyone does it but it's not necessarily required because I could go in here and I could not indent all of this stuff here and I can save it and I can run it and it still works but the issue is is is that it's not clear what's going on here because developers just know that hey this is in a class this should be indented so if it's not you're gonna introduce confusion and the only other thing I wanted to talk about in this video is this static keyword and this is one of those things that's a little bit more hard to explain without a lot of the the back knowledge of object-oriented programming we're going to dive into object-oriented programming deep in this series but just so you guys know Java is an example of an object-oriented programming language in an object-oriented programming language we basically will create instances of classes so you can consider a class like this blueprint it's like a factory that makes these objects and this probably is like making absolutely no sense if you've never really gotten into object-oriented static keyword is saying is that hey we don't actually have to create any instances to use this method here so if we created a different method let me just copy paste this and we'll just call this something really creative and I'm just gonna get rid of this here and we'll talk about that soon too and I'm gonna get rid of this static keyword and we're just gonna make this say hello their tacos if we wanted to run this tacos method or call it we would have to do it like so by doing this we're creating an instance of that class and then we could say X dot tacos like that and now when we run this application it says hello their tacos so this whole concept of this new and then putting your class name well this is creating an object but this main method has this static keyword and what that means is that this step does not have to happen and that's similar to this print line method because we're not creating an instance of this we're not saying new system and then giving it a variable name and then calling print line on it we're just calling it directly and that's made possible because of the static keyword so I'm gonna get rid of this actually I'm just gonna get rid of all this alright and also if you guys didn't realize this you can put two forward slashes to make a comment this is going to be ignored and it's not gonna execute anything so I'm gonna use comments to sum up this video and say all of the key terms you guys need to know so the first thing is the class class contains everything and has members the examples of members are methods which do something and then properties which store something these things can be given an access modifier in this case they're public so that's this right here this defines what code can use this and then lastly we had static which means no instance of the class is needed which brings up the term object which is just an instance of a class in these last few here can be a little bit confusing without first learning some basic Java so we're gonna get into these a lot more in the upcoming videos so before I go I just wanted to say that we have created this main function so this means that we created this section of code that someone can call and say hey we want to run everything inside of main and then it's going to go through and execute all of the statements and a statement is just telling the computer to do something so we've defined this main function but how exactly does it get call well the way it works is that the main function always gets executed automatically when we execute our program that means if we change the name of this thing to something totally different and then tried to run our program it's not gonna know where to start it says right here please define the main method so that means every single program at some point is going to need a main method and there is an exception to that which is if you're just creating some code that can be used by other programs so like a library well then you don't need a point to start executing you can just basically make all these resources for people to use okay so in the next video what we're gonna do is we're gonna talk about what this is right here and these are known as arguments and in the next video we're gonna talk about how we can use these arguments to make our program a bit more dynamic so hopefully by the end of that video and maybe a few more videos in you have a really solid understanding of all the foundational Java content so let me know what you guys think was this video too much did you like getting everything up front or do you think it'd been better to space this content out over some more videos like I said we're gonna go back and we're going to touch on each one of these topics in a lot detail so don't feel like you have to have everything memorized or understand every piece of it just get the basics and understand that this is the foundation of a Java program if you've enjoyed the series so far I just ask that you would consider subscribing as well as checking out the description for a link to the crash course the blog and our sponsor cramp for some interview practice thanks and I'll see you guys in the next one [Music]
Info
Channel: Caleb Curry
Views: 235,037
Rating: 4.94945 out of 5
Keywords: java tutorial, java tutorial for beginners, tutorial 3, coding, code, programmer, programming, understanding, java foundation, caleb, curry, calebthevideomaker2, java (programming language), java (software)
Id: ovb8njlzvlA
Channel Id: undefined
Length: 11min 28sec (688 seconds)
Published: Mon Nov 26 2018
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.