A Rookie's Guide to Java Part 1 - Getting Started | Harry Wainwright | Skillshare

A Rookie's Guide to Java Part 1 - Getting Started

Harry Wainwright, BSc Software Engineer

Play Speed
  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x
8 Lessons (29m)
    • 1. Class Introduction: Getting Started

      0:39
    • 2. Installing Your IDE

      4:31
    • 3. The "Hello World" Program

      4:38
    • 4. Variables - Strings

      3:23
    • 5. Variables - Integers

      1:58
    • 6. Concatenation

      4:01
    • 7. Basic Mathematics in Java

      5:59
    • 8. Basic Mathematics in Java Part 2

      4:20

About This Class

The first class in A Rookie's Guide to Java, we cover the very basics of java programming, intended for all new programmers. 

A Rookie's Guide to Java, previously released on Udemy currently holds a 5-star rating and boasts hundreds of happy students. Now I'm bringing it to Skillshare! A Rookie's Guide to Java assumes no prior programming knowledge. We start at the very basics and work our way up to some fairly advanced topics, including Java Swing. This course comes with written material to recap what you've learned at predetermined points. This truly is one of the best ways to learn.

I often see courses claiming that you can "Learn To Make Video Games (No Programming Needed!)" But unfortunately if you want to make anything more advanced than flappy bird you'll need a programming language under your belt. Learning programming is fundamental to any career in the software industry, games or otherwise, and Java is a great starting point.

Java is the most widely used programming language currently so you cannot go wrong by getting to grips with it. It holds a heavy focus on the "Object Orientated" part of "Object Orientated Programming" and as such it is a subject that features heavily in this course. 

Transcripts

1. Class Introduction: Getting Started: or island. So this will be the first section in a rookie's got to Java. We'll be starting slowly, Uh, because I'm assuming you're beginning. If you've done a better job program in before, this probably won't be necessary. We are really covering the very basics. Eso This includes variables. We do a bit working variables, and after we install software, move on to concoct nation and basic mathematics. After that, it's really not difficult. If you don't program in before, then you probably able to just skip. It might be worth watching just for the syntax changes. And if you are completely needs problem in, we take it really slow, so I wouldn't be worried at all. 2. Installing Your IDE: the curriculum, so they were going to be installing our I. D or integrated development environment. Uh, one idea is the piece of software that used Pergament essentially, uh, dependent on what language you use will dictate what I d. You use jobs, An open source language. We've got several different choices. Competent choices of which development environment to use. I'm going to stick with that beans today simply because it's the one I'll store that. It really doesn't matter if you want to use Eclipse. Look it up. Go ahead. It's Ah, it's a free world. And so let's start by going to the net. Means exceeded big download button here just hit up, and then we're hit with a bunch of different choices. So kind of the standard edition of the Enterprise Edition. This includes some Web development stuff, more Web development stuff, c++. If you got a hatred against visual studio, the problem of this download pages is include the sdk. So instead of using that was gonna go to Java, STK top buying. That said the first link here um, they will include the download to the Java J d k. My brother say you can download that if you want to download the I d separately. Or you could just hit this big born here which will include birth, that means and the J. T. K. Obviously, your selection is gonna depend on what computer you're using. And Lennox 3 to 64 Mac os Andi Windows that a bit they two and 64. I need to find out what version of windows using, um right click this PC or whatever is on your operating system gets properties. You'll tell me there. So I'm on the 64 But so that is the Virgin initial use except loss and screaming on down Idol should start. It'll take a couple of minutes, so will reconvene after that's finished again. So after I'd download's finished, we just want to open it up. Oh, instantly start installing. So it's here. Told you base it was, and still is installing the J. D. K. Andi. The Net means idea, In case you're wondering, is the standard edition. I believe it says that somewhere was on the last page. Yeah, Joe s C download. So you get in the standard edition. No enterprise edition. Uh, still size is about Sandra makes not massive So this is kind of important. You need the J, t K and the I d to be in similar locations. Default locations will be fine. So it's gonna change. Well, just make sure that you are Are you confident they don't put this somewhere still picks? You will need to find it later. Keep it next, keep it in still the it will start the process. It's obviously 100 makes So it may take a few minutes depending on your computer speed. So we'll reconvene in a minute. A good again. So after the install has finished ah, you bolts the screen click finish obviously And then we could just type in our That means if you got desktop Shoko don't know if I have actually the added so good them and then we have thean installation of on. That means that he finished 3. The "Hello World" Program: Okay, then. So today we're going to be doing our hello world program. Obviously, if you follow that another of my courses or if you ever learned another programming language you'll know Hello. World Program is just a really simple program that allows you to output of text to the consul. Uh, you do basically what? Have you learned Another language? Just get you associated with the syntax and what not. So when you started that bean, should we take it to a page similar to this or exactly like this? Ah, this won't show on truck stop if you don't take this box. But to you, craft First project is go to file new projects and you get a bunch of different options. Obviously within a job, Of course. So we simply on Java application later on, in the course, we might look into swing applications, but John replication is fine for now. So this is where you choose your project name? I'm deal. Project location. I'm gonna leave in the default location for now. If change it, then just take care. Eso naming convention is also important. Ah, I was going to call it Hello world. I think I'm names always taken up Slicks already used it. But the you too may Hello, world. We'll see. Is that one apparently So you see here that every word in the project name starts with a capital. It's not important at the moment that later on it will become important because he could see also in the main class down here is used the project name. You have to, but we're going to for now. So when you click finish, you were brought to a page like this. This is basically what you see when you create this type of project, eso got package which the project name don't need that. Leave it there. Public class mostly project name again. This is what we're going to focus on today. This main function here, um, main function is well, what runs when you run your programs? If I were to click this play button appear to start the program, the program and Whyfors ran in here will run. So this is where we're gonna Hello world. So unlike Pathan and C plus plus, there's no kind of dedicated way to print the council. Can I just have to fudge it? Eso doesn't look as Nias Python else equals, but it works. So we're gonna using system out. Don't print system The out of print Xia feature of Net beans is as we go along. It will fill in the blanks for us. Essentially. So you see this best I'm a couple of different options. Gonna print Prince Careful print line. I was going to print if I could spell you see, with print It shows all of the different variables that we can print out using print two strings billions. Charles doubles floats in his lungs. I will stay with strings for now. Printout string. We have to surround it with quotation marks. Seven exclamation mark instead. So this system out print, that is the essentially function. And then it's going to print whatever is inside of thes two quotation marks here. Andi, what we have inside these two quotation marks is Hello, world. He's gotta finish off line with a semi colon. It's the same in C plus plus you have to do in Python, I believe, after the impact from the um beating in Java and C plus plus the Semeka Long just indicates that you finished the line it's now. If we run it, council is gonna pop up down here. You see? It starts here with run. Just prints out. Hello, World Super Super Super Simple, that is. Ah, hello. Will program in Java. 4. Variables - Strings: Okay, then. So today we're going to be introducing variables. Variables are a way off storing information for future use. Essentially, it doesn't make whole our sense in the moment. But it will become very clear as we go along. So the first thing we have to do when creating a variable is specify what type is gonna be . So where is going to create a variable to replace hello world here So we don't after literally type hello world in the system print function. So hello, World is a sentence. It's a collection of words, so we're gonna create type string in program. In lingo, a string is basically a sentence. They're more complicated than that. But it's a grouping off characters. It's not being treated. There's a number essentially doesn't make sense again. That we come clear is we go low but we specifies a time string and then we give the variable name I was gonna call mine Words obviously followed with the semi colon. So this lines I mean, much of the moment we've created a string called words, but there's nothing in words is on empty variable to put something into it. And we have to. Yeah, do the following. So is this string. We're gonna need the quotation marks again, but words equals hello world. I call it something different, actually. Uh, my name is Harry. Just a mix up of it. So we've created are variable string woods. We've put something into words. The sentence. My name is Harry. Now we've just got to use words. So in our system out print function down here. Uh, which is currently still printing Hello world. You know, just delete this bit, including the quotation marks and type in words. You notice that it doesn't need the quotation malls. I'll show you why in a minute. But now this is complete. Valid. So if we play this, if we run this, it will print out. My name is Harry Bill. Successful filled times Their seconds seems simple. So it's taken what's in the variable words? It checks out. Words it realizes is the strength. And inside it it's storing the sentence. My name is Harry. So it's just printing out what I was in words. If that isn't super clear in a moment, don't worry. As we go along, all this will become clear. No practice you put in, the clearer it will become. I just want to show you what happens if we surround it with quotation marks. If we surround anything with quotation marks, is taking it literally, essentially. So now, if we were in the eye, she's gonna print out words. So if printing a variable or some such thing, then ignore the quotation marks. You only use quotation marks. If you're printing it literally, that's much better. 5. Variables - Integers: so continuum with this idea of variables, we're going to introduced numbers today. All whole numbers, at the very least, whole numbers, if you have done that, math makes are known as interviews. So to create an interview, we just have to type in int a similar string. This is just the variable type, but this time it's a number rather than, ah, strength. Simple. So int Esquith age. So we're creating on a judge for from the Expos and then similar to last time with words. Let's just move this up away So you know, again, a bit confused. Ah a e g cools 20. I'm 20 years old, so I shall write 20 there. First thing I notice is that I didn't surround it with quotation marks. If I did, then Net means the pilot would think Well, hang on a minute. Ah, this is trying to store string inside of age. The age isn't in and he can't store string inside and didn't. So if you're trying to store a number, then obviously don't write it as a string. It sounds really simple when you say it like that, but it will catch a lot people out So we've got out into age here. This is pretty out. So again, light words were printing a variable. So no quotation marks just prints out 20. Simple. Right? So that is an interview. What can we do with an interview? Well, let's debate maths, I suppose. 6. Concatenation: so it's they were going to cover Can Captain ation? Ah, it's the topic. I wanted to get out the way quickly, because is is pretty boring. Ones like boring, but it becomes second native very quickly. It's something you need to know when you lose a hell of a lot, Um, and it it just falls in line very quickly. It's an easy topic. Cara Nation. So contamination is a fancy word for saying we're going to combine these variables or different strings into one in this print function. Best work shows is through example, So previously we were just printing out. 20 uh, 20 doesn't mean much. What does it mean? The user that's running this program doesn't see that it's a variable, and it doesn't see that it's a variable called age. The use of running this program would just see 20 So to make it, then we use a friendly. We could just type in in this print function if it doesn't make much sense of movement. I'll talk there at the end against our using these addition signs. We've combined this string with this variable with this string, simply using those edition signs on what's going to do is it's gonna squish it all together to form one sentence. So when we run the program, it simply says, I'm 20 years old, Perfectly formatted, takes away the addition. Size obviously won't print those look a bit silly. They just prints everything literally, including the spaces. So you notice at the end of this I am string. I've got this blank space here and at the beginning of this years old string, I've got another blank space here. That's just a former it properly. If I didn't include those, then you can guess. It just looks a bit weird. Eso we include the spaces, and that's all contamination. Is it squishes sentences and strings and ins together using these plus signs. It's the same in any programming language, and it's just really useful for formatting when the when you're trying to be more use a friend Last pot's So let's also it involved. I would string Hicks when used in a while area. It's now problems just going to say my name is Harry. I'm 20 years old. First thing you notice is we do not have a new line after this system. Output on this one. So in a consul down here says my name is Harry. No space. I'm 20 years old a couple of different ways around this. And I honestly forget how to do in Java in secrets, proceed, deal. Backslash end. And that gives a new line. So I won't see if that works. It does brilliant. So former even more. I've just added this new line onto the start off our second line. I mean, you could do this anyway you want? If I wanted Teoh, I could just can captain a it another new line at the end of this one and have exactly the same ah result so whichever way you feel comfortable doing. But that is contamination adding strings and what not together. And the new line that command is is really useful if you want to form up properly. 7. Basic Mathematics in Java: I came in. So today we're going to be doing mathematics in Java. Pretty basic mathematics, but mathematics And on the less we're gonna mainly be looking at the math Michael operators plus miners divide multiplication, etcetera. But start with we're going Teoh create. We're going to introduce a different type of variable so have already shown in Tages. Interviews are whole numbers, So I'm sure somebody was scratching heads in last. The last video when we introduced these. So after the feeling of decimal place What? What does happen if you try and right? That's more place in an interview. When we get this hour here, you've just hovered. That will tell you why eso says incompatible types possible lossy conversion from double to int. It tells you the next time I'm gonna introduce right there, which is a double. So try to run that we're gonna get errors. A lot of projects was compiled with errors, so forget about that's not gonna work. So I told us in the aromatics there what we have today if we want our variable to include the best more place, we're gonna have to write it as a double. So I am 20.5 years old, Very specific. Ah, you see, we've got different ever there for a different reason, which I'll go into the end. But for now, let's just let's just rename it to specific age. Now, if we run this, it's obviously not gonna print outside and print out, but it runs fine. We didn't get the same error message that we did last time. So what we've done is create a double. A double is at a number that allows decimal places. Essentially, there's a couple of different types that you can use in Java. You can use flows. He can use long doubles, but we're going to use doubles, uh, foreign against for every reason. But, you know, this is beginner's course. If you really are interested in specifics, then you're welcome to go look it up. But for all intents and purposes, just taking one for it. We're gonna use doubles eso You'll notice the naming convention. We have to change it. Why did we have to change it? Well previously? This calls an error on if you horror hover every CSI. Why pickles now? Variable ages already defined in method main, so in method main. We've already got a variable called Age, So this is my first kind of hint that you can't have two variables of the same name. Ah, the compiler won't be able to tell the difference. At one point. He call in age and integer, and it's got 20 stored in it, at one point equal in age a double. It's got 20.5 stored in it. It will make any sense the computer. It doesn't make any sense t towards if you don't think about it, so I gotta call it something different. Stockelman Specific age you'll notice is it's two words. I only capitalized the words on the second letter and beyond every phone call it specific age number, capitalized number as well, naming conventions important. But we weren't going to detail until later on. So writing is a double were allowed to do decimal places. Really simple. So let's have these numbers together. Maybe so. I'm just gonna do it in the system out for now. So let's do age ab, but wage age add specific. Let's just get rid of this line. 40.5. So all we did is add this edition sign here now some of you are thinking already. But what about contamination? Wasn't the last video just talking about how we're still just smush it together? Well, yes, If these were literally Rennes strings, if this was a 20 instead of age and this was a 20.5 instead of specific age. In that case, it just can cat maimed together. And we get this Tuesday or 20.5. But as they are not in quotation marks on their variables, we've established the numbers. Then this addition, Zion treats them as if they were numbers Onda. We get 40.5 instead, and this is the same with any mathematical operator you can think off as they're being treated as numbers as they've been defined as numbers up here as variables. Then we can multiply them using an asterisk. It's for engine 10 points area, apparently. Ah, we can divide them using a divide sign or sorry, forward slash, which is that long number. And we could subtract them, obviously using a subtraction sign minus 0.5. So super super simple mathematics, very basic example. We'll go into more detail in the next video 8. Basic Mathematics in Java Part 2: so I want to do a bit more on mathematics. Last tutorial. We just covered it within this print function here. I want to say that that's not necessarily how you have to do it. Ah, some of you probably went toe especially forwarded on the Parliament, but you can do your mathematics service within a variable. So if we just have cracked the variable called double Answer, for example, um, we need to do answer equals H plus specific age. Or we can say on the declaration. Linus, we did hear with specific age. So for do double answer equals age on specific age and then said, changing this line every time we could just Apple answer. It's not necessary. Or but having another variable answer that you could use somewhere else in different, um, indifferent mathematical functions that that'd be useful. I'm sure you can admit, so let's have answer equals specific age there. Then print that. I did a lot for a reason. I want to demonstrate why in a momento. So if you were in that a looks farm, we have put 40.5 one now happens if you won't answer equals age minus specific age. What is gonna happen here? Show some of you have already picked up on it. Um, we're already using answer here. Where was saying answer to this, which is age plus specific age. So what is it? Was it gonna print when we have two lines both coming in to do something different? This gives an insight into what the compiler actually does, and he said he gives us minus 0.5. So why is this? Well, Jova and well, every programming language pretty much works from top to bottom. So when you run the program, it runs this main function, and he goes through the main function line by line, by line by line. So first it sets up the string words, and it adds something to this new variable that says a age sets age to 20 says a specific age, says it's 25. That's the answer. It is this line, whereas them together. So at the end of this line here, answer is equal to 40.5. Then on the next line, we ever write that. So answer is is it minus their 0.5? That's all that's happening there. It works from top to bottom. So if you ever I variable name like this, then you've got to You've got to be aware you got to keep track of variable name. Essentially. So a better way to do this would, instead of having a generic answer variable, we have, in addition variable and then they minus variable. Now it's gonna print out. Ah, now we're gonna have both of answers. See? So 40.5 there next line down minus their 0.5 is its simple idea. But I thought it was worth mentioning in the seas, Orel, Because keeping track of your variables, it is good co design. If you have a generic variable name like answer when you're going through the program later on, all that you're going to think of is what his answer. It's gonna take time if you scroll up to find out what answer is actually doing