Java Programming: Learn Basic Java Code with NetBeans | Matthew Dewey | Skillshare

Java Programming: Learn Basic Java Code with NetBeans

Matthew Dewey, Writer, Writing Tutor

Java Programming: Learn Basic Java Code with NetBeans

Matthew Dewey, Writer, Writing Tutor

Play Speed
  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x
9 Lessons (34m)
    • 1. Introduction to Java Programming: Learn Basic Java Code with NetBeans

      1:26
    • 2. How to Install Netbeans

      2:31
    • 3. Your First Line of Code

      5:52
    • 4. String and Integer Variables

      5:11
    • 5. Math with Integer Variables

      2:57
    • 6. If Statements

      4:49
    • 7. While Loops

      3:46
    • 8. Basic Input

      3:27
    • 9. Parsing Variables

      3:42
  • --
  • Beginner level
  • Intermediate level
  • Advanced level
  • All levels
  • Beg/Int level
  • Int/Adv level

Community Generated

The level is determined by a majority opinion of students who have reviewed this class. The teacher's recommendation is shown until at least 5 student responses are collected.

411

Students

--

Projects

About This Class

In this series of videos I will teach you the very basics of programming using Java. A hands on approach here is required. It is better to write and run the code yourself than to discuss it without actually programming. By the end of the course you will have a firm foundation on which to build your programming knowledge.

Meet Your Teacher

Teacher Profile Image

Matthew Dewey

Writer, Writing Tutor

Teacher

I have been writing and teaching for years, helping tens-of-thousands of students achieve their goals, be it completing their novel or publishing their work. Having written several novels, non-fiction books, hundreds of short stories and articles, I have studied and put into practice the best methods for writing effectively and efficiently.

In addition to writing, I am also a programmer and artist, teaching what I know on the subject and helping those interested get a headstart.

If you want to write a novel, a story that has been on your mind and not on paper for too long, my courses will not only help you start, but I will be there as well. Any work you submit, I will happily read, review. If you need professional advice or a friendly opinion, I will be there for both.See full profile

Class Ratings

Expectations Met?
  • Exceeded!
    0%
  • Yes
    0%
  • Somewhat
    0%
  • Not really
    0%
Reviews Archive

In October 2018, we updated our review system to improve the way we collect feedback. Below are the reviews written before that update.

Your creative journey starts here.

  • Unlimited access to every class
  • Supportive online creative community
  • Learn offline with Skillshare’s app

Why Join Skillshare?

Take award-winning Skillshare Original Classes

Each class has short lessons, hands-on projects

Your membership supports Skillshare teachers

Learn From Anywhere

Take classes on the go with the Skillshare app. Stream or download to watch on the plane, the subway, or wherever you learn best.

phone

Transcripts

1. Introduction to Java Programming: Learn Basic Java Code with NetBeans: hello and welcome to basic job script programming. Using the neck means body mining. Is Matthew doing? I've studied programming for four years and have become proficient involved languages from C Shop C plus plus Pathom and, of course, javascript. And then, ah, me Just start by answering an important question. First of all, what? Javascript. John. A script is easy to understand. Java script, unlike most programming languages, incorporates more of the English language allowing you to understand code. Greta JavaScript is osa Universal. Most programs today make use of JavaScript. Not only that, but the concepts you learn in JavaScript progeny early off programming languages making it easier to learn a new on. The goal of this listen is to teach you how to use it means as well as the core fundamentals. You need to know as a programmer from installing nicknames your basic important Albert. So without further ado, let's begin. Okay. In the next video, I'll show you out installing it means so we can get started. Coney 2. How to Install Netbeans: Adam. And in this video, I'm going to show you how to install Net means. First, go to your browser and topping the search ball niche beans. The first option will be Net Means RD Donald. This is the correct one. When the page comes up, you have a variety of different downloads to slipped. You may choose either this one or this one doesn't really matter which I currently use this one because it takes up less space. Click download and wait for it to finish. When it is finished, you'll get a fire like this. Double click on the phone. It may ask you for administration access. Click ease except Next, Matt Usual destination. I think I'll leave it as is check updates and store. When the installation is finished, it will show you this message. Always uncheck this box because I find it unnecessary and click finish. Once it is complete, your now I have this icon on your desktop. This is nit beans, double click to open. It may take a while of first time, but that's just it sitting up. It may be fostered in the next time you open it. Here's your program finished and stored. Now, first part, I'm gonna show, you know something extra. Turn off the start page. It is another unnecessary future. I'm not going to show you where everything is at the moment, but I will show you an extra add on which I find very useful when recording and programming go to available plug ins. Top in dark, the very top. You'll find dark look and feel themes. I prefer using this because it adds a new sort of skin to the it means RD, which would have found better to look at them. The stock. Watch off the screen. Simple installation again. Click. Next click I accept and clicking store. It shouldn't take too long, but I ask you to restart, Click finish and there we go. As you can tell, reading is completely different. Look to it. Everything is weird was before, but you noticed that the color is now much easier now. In the next video, I'll show you how to create projects in it beans as well as your first line of code 3. Your First Line of Code: Hello and welcome back to your basic job of programming course. In this video, I'm going to show you how to create a project as well as your first line of code. Now, before we begin, we have to start creating projects. And to do that, there are two methods. One is clicking new project here, which is what I usually do. I find it quicker, but then they are create new project using this folder. You can also find it. Yeah, if you want a quick click. But I prefer using this method. Create a new project. When this box comes up. Double click on Java application. Since we are creating a Java program, this is the correct one to use as it comes up. All the co in a need. Now, let's name our Java application. Since our first program, we're just gonna call it first. Now it's gonna start to sit up your project where you can start coding. And as you could see, a lot of things have changed. First of all, we have a new box here and our code bar boxes appear to you as well. Over here you will find our projects as you could see first breaks down into several boxes and told, Gets to this one of the year first dot java. This is our main program. So when opening your job application once more, you have to open several boxes and in double click on your job application and to show you what would happen. I'm gonna close this box and double click on this. It reappears. This box is where you'll be doing your coding. Ignore the comments because these are the pre generated comments that come with or applications. You can delete them because they're not necessary. Comments are usually shown by these symbols over here, the Ford Slash. Here, this is your also Matthew, that is the name of my computer to amateurs will be different. So don't worry. If it is just start coding. We're gonna first identify three things. One is package First public cast, first public static void. Main package. First is talking, of course, about your package for your job application. So here it is. Package first and then your job application. The public class is the program itself. Everything in between these brackets is the code, as you could see there highlighted in green are that have selected them. And, finally, public static void Main. This is a traditional line of Kurt, which identifies with the main code is going to be written. This comment is just telling you the that right now to do application logic. Yeah. Now we're going to start our coding here to do that. Click our enter after here. Now you're started on a fresh blood. Now, here's our first line of code. Write it out exactly as I do. System docked out dot Print l in brackets Sumako. Inside these brackets, I'm gonna put in quotation marks. Noticed when you put in your quotation marks, a 2nd 1 appears because it expects you to fit something in between those two. So I'm gonna rot in between these two quotation marks. Hello, world. Now, let's I don't afar what this line of code is. And guess what the result will be. System system is referring to the coding system that you see before you the i d out. This means output print. Ellen print is self explanatory. It's gonna print something. This is not necessary. At the moment you can simply destroyed print, but l in create a new land once this has been written. So if you haven't guessed it already, this code will bring down a lan or ticks in the output box. And this text will be Hello, world. Now to show you how it works. There's two ways to run the program if six which is a short cut key for the green button of a year run project. So let's do that. Hello, World build successful. This is customary land that appears after each line of code is rooted. Hello, world. Now show you what Print and print, Lon. I'm gonna remove that, Ellen and run the program once more. As you can see, it did not create a new alarm. So there, General Kurd, that appears after your output is now being placed right next to hello world. So let's fix that because it makes it a logical on the program again. Hello, world. In the next video, I'm gonna teach you how to use variables starting with string and into 4. String and Integer Variables: Hello. And in this Listen, I'm gonna teach you how to use variables. First, let's open up our project. We go to our project Java icon, which is first click this. Collect the source packages, click first package, and then you'll get first dodge. Other as you know, this is our program that we've been working on. It has the green play button which symbolizes that it could be run, double click, And then we have our code from the last video. Now I'm gonna raise his coat and start by showing you how to create a string variable. First we topping ST and the new top in the name of the variable that you want to create, which we're gonna call would. First question you're probably thinking is what is the string? A string is a lot of text, so essentially we're creating a lot of text Variable. Now we're gonna show you how to give the variable value. They are too simple ways you can do that. One is you can give its the value by saying would equals. And since its text, we use quotations and they would say hello on the quotations. And as with all lines of code were closed off a semicolon. Now that variable has a value. Its value is Hello. How do we see this valley when we run the program the same way with every show or text system out Prince Alan. Now, since we want to print a variable, we don't use quotations we don't print to the actual would would. So we're gonna print it as would without quotations. That is a when you run the program. Hello. Just as we gave its value, it has now been put it on our output box. Now, the second way in which you could give of it. Now, the second way in which you can give a variable value is by saying would equals Hello. You don't have to write a second line of code you can give. It is very straight in the same line. Run the program. Hello is printed. Now you can use this with other lines of text such as, Let's say, let's change the name of this variable to name and inside it I'm gonna run massive because that's my name. And now you notice this isn't red because would is no longer available, So we'll say name there. A message is gone. Now we're gonna combine two lines. One was available and one just simple quotation writing. We first create our quotations right where we want to say so. Hello. My name is and we put a plus son in between the two. This shows that we're creating a long line of text and in Islamic texts were including Hello, my name is and the variable name. Now, as you've probably already guessed, what it's gonna print is Hello. My name is Matthew. It got this value from the variable. However, this land over here was already pre generated. So who if it changes they name to, let's say, instead of Matthew, they say, John, when you run this line of code Hello, My name is John and it's a simple is that variable can be used as many times as you'd like , as long as it is used correctly. Now I'm gonna show you one more thing a second top of able a number variable or as we call them, an integer to create an integer variable. We top it int short and simple and listen scored numb for number into numb into numb is a number as you can guess. We can also give it about me this time since it is not text but rather and number we just say into equals five for, uh it now has value. So then we can now add that into our Lon as well. Hello. My name is name plus and I am plus no. Well, as you can guess when you run the program again. My name is John and I am five. Num is simple as string. The only difference being is when you give it its value You don't use quotation. 5. Math with Integer Variables: Hello and welcome back to your Java programming course in this video, I'm going to show you the mathematics with vintage of variables before we begin. Let's start by creating inter to variable, so in none. And let's give it a valley off five and close of the semi coat on. We now have a variable, and we have given it a value. Now I'm gonna show you four different parameters that we're going to use addition, subtraction, division and multiplication. Now, first, we print our results. So we create our system of print line and we put in them. Now I'm gonna show you thes four parameters. Let's start with addition. It's a simple was a pleasure. So numb. Plus, I thought, When we run our program, the result is 10. Just a simple mathematics goes. Addition does not change. Now let's go for subtraction. But to replace the plus on with a minus and run the program subtraction. Simple as always. And now let's move on to something slightly different division and multiplication. So division we do not use a divide symbol. Instead, we use a forward slash run. The program, five door before is indeed one now Let's move on to multiplication. Multiplication is not a Exxon. It is a star son shift eight When we run it numb terms. 5 25 Which is correct, These other mathematics with individuals. Now we can also use the same things with different variables. So that's great. Int num too equals five and replace five in the system are print line with Numb to the result should be the same 25 changes of any to 10 and run it. The result is 50. We could go even further and just great assertive able int result and give the equation No Tom's Number two and then just Prince Salt. Just as before, these are the different ways you can use interview. 6. If Statements: hello and welcome to your Java programming course. And in this video, we're gonna continue working with if statements, as we saw in the last episode, weaken chicken integer to see if it is below a certain number or buffers of the number for equal to it. In this episode, we're gonna deal to scenario if we have to choose a number between two other numbers, and how do we check to see if that interject fills the requirements? So to do so, let's first create our interview. Int num equals is safe 15. And now we need to create an if statement that's able Jew check If let's say that number is in between 10 and 20 now, to do that with topping our if statement, if no is greater than or equal to 10. Okay, so now we know that it's checking to see if the numbers above will equal to 10. But how do we check if it's in between? Well, let's see if our or that we learned to the last video helps us. The so numb is listen and you're in 20. Create our brackets and let's just say yes in our system. Our front line. So now this should work if our number is above equal 10 or if our number is less than 20. So let's try it out now. At Prince. Yes, which is correct. 15 is in between 10 and 20. Let's see if our if statement works for numbers that aren't in between 10 and 20. Let's say 25 it Prince. Yes. Again. How is this possible? We have created an if statement that says the numbers in between 10 and 20 25 is not in between those two. So how is it printing? Yes, it's because they're all allows it to be one or the other. So it doesn't have to fulfill both requirements. It just needs to fulfill one. So in this case, it fulfils the first requirement number is greater than I want you to. 10 and 25 is greater than 10. So it prints Yes, without having to take the 2nd 1 If numbers below 10 it would do the same thing. It will signal the first parameter which it doesn't fulfill. Look at the 2nd 15 is definitely less than 20. So it was still Prince? Yes. So how do we fix this problem? Well, this is where the end comes in. We double tap a and symbol shifted seven, and we've created end. And what this does is it compares both of them and funds were both the meat. In this case, they're both meet between 10 and 20 inclusive. So when we run the program, it doesn't print anything. But if we top in 10 it princey is if we top in 15 prince, he is 20. It's in but above 20. It does not. So if statement has done exactly what we hope to do, it has checked the inter gin and found out if the number is in between two, so two numbers now, let's pose an easier scenario to end off on. Let's say we create a player run, and only Children below the age of 12 are allowed on it. So what will be right in our if statement to determine where the integer is 12 or below? I recommend pausing the video here and trying to do it yourself on pause. When you have completed your task and I'll show you the answer came Let's work on It now has changed. First, the numb to something that fits our if statement. So let's say 10. And our if statement will be number is less than or equally 12. When you run the program, it prints. Yes, it works the same free topping 12 and if it is above, it does not run exactly as we hoped. 7. While Loops: Hello and welcome to your job. A programming course. And in this video we're going to be working with loops. Now. A loop is what we program is used to repeat lands of code, be it a single line of code or an entire section. We use loops to save Tom and to avoid writing the same lines of code again and again when it's not necessary. So I'm going to show you the most basic loop first, which is a while loop. And to show you how to use a while lip, I'm gonna first start by creating account. Variable account variable is just a normal invaluable and count equals zero. We're gonna use this variable to count how many terms the loop is going to repeat. So let's say we want the loop therapy. 10 times were an effort that in the clothes off a wildly So let's do that right now. Top in a while. Open up brackets to put in the clothes so our account is not equal to, and we're top how many times you want to look to run. So let's say 10 times like the if statement to open up on the curly brackets and top what we want inside. In between these brackets, we're going to have a count Adah. So to do that, we top in count plus. Plus, what this does is add one to the counter variable each time the loop is run. So each time, the Blue Peron's account will add one to its value. The second time it'll run. It'll have to the 3rd 3 and so on. And to show you this output is gonna be the count variable itself. So we shall run the program and we'll notice it does exactly that. 123 all the way up to 10. And the reason it stopped there is because while count is not on the 10 So when the count had changed to 10 it had stopped a loop and ended the code. So I'm gonna show you something else. What would happen if I move the count plus plus two beyond the output? Well, it will start from zero, because when the loop runs, it runs in the order that is displayed in between the brackets. So in this case, it would print the count before even added the one and the count as we declared is zero. So Prince zero instead of printing 10 once more the moment it has turned 10 the loop ends before can even print out the number 10 and that is a while loop. A simple is that Suppose we want to print a Siri's off, even numbers ranging from 2 to 10? Well, in that case, we wouldn't use the count plus plus because that only adds one. Therefore, we will get odd numbers into the mix, so to solve that we top count equals count to. This is similar to count plus plus, but Accomplice Plus is counter plus one. In this case, we do encounter press two and then we displaying count. It should now print a serious off even numbers ranging from 2 to 10. And it does. Indeed, this is a while. It's very simple to understand, and the clauses are very easy to come up with passages practicing with while loops using different types of output, such as strength 8. Basic Input: Hello and welcome to your job. A programming course. And in this video, I'm going to show you how it input values through a input box. Now, before we begin, what we're gonna learn today is known as the J Option pain code and the only way to use his codas. If we import the right assets to import assets, you must go to your package First presenter after it and top import and other package we are importing is a job x wing package. So we chop in Java, the ex swing, and we're gonna put dot star, which means we're gonna import everything in the swing package. It's not necessary. We can just import the jail option code for dry at the moment. I believe the star method is easier in case you have to use other J option code further on , and we closed for semi Colon. Now we begin coding first line of code we're gonna create is the J option paying itself. We're gonna first create a variable for the J option pain to input in. So let's create a string in putting able. So we're talking string and let's say Would will be are variable name and not to give it its very click equals and always And it occurred at the top here is different from normal. Instead of opening up quotation marks and topping what you wanted to have, we're going to have Jay Option could Now the J option could is what summons that girl from the job X swing assets and allows us to input whatever we want into an input box. So two top is good out topping J o Capital J. You know, option capital P a N E docked show input dialogue. And we have quotations in the brackets and closer to Sydney. Coat on. Now, write this code word for word. It is case sensitive, so make sure you have capital letters where you see capital letters. Yeah, and a now input box. We're gonna top into a wood eso. You could see what the import dialog looks like. Let's just run and see. As you can see, it has input that asks us into a word as we've written in the quotation marks and it gives us a box to top what we want and then in OK or cancel. So with top Hello, you noticed nothing has happened because we have yet to add the output. Good. So let's add that now with great our sister, our print instead of quotation marks will topping would so it should print whatever words value is. So we run the program again, but it's talking test click OK, and why are put is test. We have now learned how to input into variables. 9. Parsing Variables: hello and welcome to your Java programming course. And in this video we discuss how to convert images into strings and strings and two in judges. Now this process is known as passing. When you passed a variable, it means you transform from what variable is into another. So let's begin by first creating a string variable, and we're gonna convert it into an integer. It's string test equals and let's put it in a number, which we're gonna convert to interject. So let's say, 15 and clothes of a semi coat on. And now let's create an invariable that we want to convert the test variable into. We first take int num equals and we top in the following code in teacher dot parse closer Sima Khan and we ive test and we have test in between the brackets. But this does. It converts a string test into a number, and this number is then stored within into numb. So now let's sister my print numb so we can see the result. And as you can see, it was successful and converting the string enter an integer. Next, we're gonna convert an integer into string to do so. That's great and invariable and test equals and has given the same value 15. Next we're gonna top in string lt'd equals And now unlock the inter job passing. All we have to do is great quotation marks, a plus sun and then the variable test close of a cynical on This is all we need to do to convert an integer to a strength. So let's show the result with a system our print and we have now successfully converted an integer into a strict. So now I'm gonna show you how it would work when you're in putting values. So let's suppose like in the last episode, we decided to in put in number instead of a string. So we create our into variable Let's leave it as test and we talked in t J don't pass. And within the bracket system, we add our J option pain dot show input dialogue. Henry asked user to enter a number. This is all you need to do to convert a string into in ginger when using an input dialogue . So now we print the result test and run the program. It's topping 15 click OK, and they're successful to make sure we'll add a number to it and see if it works. It's talking. 15 20 is indeed printed, so it is definitely integer and is no longer a string. Now, of course, we don't need it added converter when using J option pain because Jay up champagne by default inputs straight.