Java Programming: Learn Basic Code for Beginners with NetBeans in 2020 | Matthew Dewey | Skillshare

Java Programming: Learn Basic Code for Beginners with NetBeans in 2020

Matthew Dewey, Writer, Writing Tutor

Java Programming: Learn Basic Code for Beginners with NetBeans in 2020

Matthew Dewey, Writer, Writing Tutor

Play Speed
  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x
66 Lessons (4h 60m)
    • 1. Introduction to Java Programming with NetBeans

      1:29
    • 2. NetBeans Download and Installation

      3:50
    • 3. Your First Line Of Code

      11:28
    • 4. Strings and Integers

      9:16
    • 5. Mathematics with Integer Variables

      6:05
    • 6. If Statements

      10:47
    • 7. If Statements and Additional Operators

      7:42
    • 8. The While Loop

      5:14
    • 9. The For Loop

      4:01
    • 10. Retrieving User Input

      6:07
    • 11. String and Integer Parsing

      5:56
    • 12. Character Data Type and Parsing

      6:20
    • 13. Double Data Type and Parsing

      6:22
    • 14. Project 1 Discussion

      2:10
    • 15. Project 2 Answer

      7:52
    • 16. Introduction to Advanced Java with NetBeans

      1:14
    • 17. The toUpperCase Method

      3:05
    • 18. The toLowerCase Method

      3:15
    • 19. The isLetter Method

      5:00
    • 20. The isDigit Method

      2:55
    • 21. The isWhiteSpace Method

      3:18
    • 22. The Length Method

      3:43
    • 23. The compareTo Method

      8:16
    • 24. Project 2 Discussion

      2:25
    • 25. Project 2 Answer

      11:45
    • 26. Conclusion to Section 1

      0:43
    • 27. Introduction to Section 2

      1:19
    • 28. Substring Introduction

      3:01
    • 29. Substring Practice

      5:01
    • 30. indexOf Introduction

      3:15
    • 31. indexOf Practice

      7:58
    • 32. Project 3 Discussion

      1:38
    • 33. Project 3 Answer

      6:17
    • 34. Conclusion to Section 2

      0:51
    • 35. Introduction to Section 3

      1:22
    • 36. Scanner Introduction

      3:02
    • 37. Scanner Practice

      6:57
    • 38. Delimiters and Basic Error

      5:48
    • 39. File Reading Introduction

      2:45
    • 40. File Reading Prep

      1:57
    • 41. File Reading Practice

      5:38
    • 42. PrintWriter Introduction

      2:37
    • 43. PrintWriter Practice

      6:20
    • 44. Try and Catch

      3:40
    • 45. Project 4 Discussion

      2:04
    • 46. Project 4 Answer

      8:09
    • 47. Conclusion to Section 3

      1:18
    • 48. Introduction to Section 4

      1:03
    • 49. Array Introduction

      2:01
    • 50. One-Dimensional Array

      4:45
    • 51. Two-Dimensional Array

      4:34
    • 52. Split Introduction

      2:36
    • 53. Split Practice

      2:53
    • 54. Project 5 Discussion

      1:16
    • 55. Project 5 Answer

      5:54
    • 56. Conclusion to Section 4

      1:15
    • 57. Introduction to Section 5

      1:40
    • 58. Classes Introduction

      2:41
    • 59. Void Method

      3:10
    • 60. Typed Method

      6:23
    • 61. Private Variables

      4:54
    • 62. Scanner Method

      3:57
    • 63. OOP Practice

      11:24
    • 64. Project 6 Discussion

      2:04
    • 65. Project 6 Answer

      14:33
    • 66. Conclusion to Java Programming: Learn Basic Code for Beginners with NetBeans

      1:28
  • --
  • 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.

104

Students

--

Projects

About This Class

Welcome to Your Basic course on Java Programming with NetBeans!

My name is Matthew Dewey. I am an experienced programmer, having received several accommodations on programming in my formal education as well as tough several programming languages to thousands of students. My goal is to provide you, the budding programmer, the knowledge you need on programming in an easy and fun manner. In this course, I do just that and with one of the most useful IDEs coupled with the Java programming language.

644714a0.png

Java, a wonderfully simple programming language that has encouraged many programmers to pursue careers involving Java over any other language. Of course, it goes without saying that Java is an excellent language, but do you know what is required of you to start programming Java?

As with any programming language it is important you understand the fundamentals and that is exactly what I teach you in this course. Further on, once completing the basic section, we move onto advanced Java programming and OOP. Data is important in the technological world that we live in, but what we use is processed data, so you, as the budding programmer need to know this as well. I show you how to scan through large amounts of data with ease as well as extract specific types and process it as well.

What about NetBeans? A popular, widely used IDE that many large applications have been created over the years. Do you know how to use it to its full potential? Well, in this course we will go through several projects that will help you get truly comfortable with the IDE as well as more adept at program creation.

You will learn how to:

  • Install your IDE

  • Establish fundamental code

  • Create and use variables

  • Retrieve user input

  • Process simple data

  • Advanced Java Methods

  • Data Collection

  • Data Processing and Storage

  • Data Extraction

  • Data Scanning

  • OOP, Object Orientated Programming

  • and BONUS tips and tricks!

Go no further if you're looking for the course that will guide you into the world of programming! With my masterclass course, I can guarantee that the knowledge you learn will help you get a head-start in Java programming. I hope you enjoy the course and it helps you on your way into the world of programming!

"Programming is a form of art. It is logical creativity!"

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 with NetBeans: Hello and welcome to your job. A masterclass with net beans. My name is Matthew. Do we lead instructor at programming dot com. I have taught Java programming for five years and studied far longer than that. In my experience, Driver is an excellent program language to work with. Not only that, but it is one of the best beginner languages to start learning programming with. If you want to start learning java, this is the course for you. The first section of the master classes, comprised of basic lectures that I help you master the fundamentals of Java programming. The next five sections of the course of the Advanced and 00 P. Studies. We learn more advanced methods and functions, eventually moving on to object orientated programming. O P is what are the essential skills off any common programmer with power. Bi can create your own classes and objects, which can be re used to your advantage. If you want to excel at programming and work effectively, you will need a P that concludes this introduction. In the next video, we'll be downloading and installing our RD net means 2. NetBeans Download and Installation: Hello and welcome to your basic Java programming course with nit beans. In this listen, we're going to download and install and it being software. First, go to your browser of choice. I'm gonna be using Google Chrome and topping the search bar Net Bean. Once there, you'll be presented here with the SAT. Welcome to knit beans at the very top of your list upon during this. Click on the following download link at the top of your sad. As you can see, they're all true that I'm gonna be available. There's going to be the patching it being Saudi, and it's going to be the Net Beans Audi A eight going to. Currently, this is the version that we'll be using throughout this course, So click on the download link over here upon clicking the link, it should take you to the side of year. This is where the dollars can be found. Now we don't want to text you of downloads. Most of the futures you won't really need for this basic course or for advance one, for that matter, in which case we're going to click on the lower option year job is E, which contains all of the programs that we need reciprocally on download. It should be free, and the sauce is 95 megawatts. Upon clicking that button, you should be presented now if this sort where it tells you that the idea is downloading. If you get this message every year, be sure to click. Keep instead of discard because you want to keep the program and install it later. Once you have downloaded the program, Once you have died of their Stoller, double click on it to turn it on and we'll begin installation straight away. You may be osteo enter in administration access. This is just the computer asking you if you really onto installs program or not. I do want to install another installer, begins Take a moment to configure, but it'll soon be done, and we can begin with the nitty gritty. It asks us now to begin the installation, so we click next and we are presented with a license agreement, which we can read through for upon completion. We're just simply click. I accept it and move on to the next day. Yeah, we decide where we want to install our program. I find it's fine just to set the defaults as they are. Click next. You now have the option for the program to check. For updates on automatically update. We'll click. Yes, for this just to stay up to date with our jobbers wells I D and click Install. Once you have done this, the installation begins, and now we simply wait to lend. Upon completion of the installation, it'll ask you, Do you want to contribute to the NIT beans project? Providing anonymous start to usage personally on Check this box, but it has no effect on your programming or your program. What saver If you want to contribute towards the NIT Beans Foundation to see how they can improve upon it means it is up to you. So once you've done that, you click finish and your installation is complete. You'll have an icon on your desktop what you should be able to activate to turn on the program. But that said, this will continue in the next Listen, when we write our first line of code, see you then 3. Your First Line Of Code: hello and welcome to your basic Java programming course with NIT beans in this list, and I'll be showing you how to create your first line of code. As you can see, I've opened the Navy beans, I d. What I'm gonna do next is create a project. A project will contain a foul which will contain our code. This is the importance of credit projects. It's the important of creating classes, classes being the name of the file. It will contain our code. With that being said, I could spend a long term going through the different features that mid beans has. But that'll be too much of a fluffing to video that is really unnecessary. Most of the core features that are installed within knit beans comes through the program that your art, these additional features that you could see here the top like plug ins and tools in a team in the profile all fairly unnecessary for what we'll be doing and what you'll be doing, even in advanced lessons. But that being said, when you start your program up, you should be presented of this start page. Simply close it. It's just a introductory page and you'll have a project spawn aside here. This is where you'll be creating your projects to create your project. You simply create a package, which can be done by clicking on this file Over here. That's his new project control Shift in, as you could see, is the short cut link to creating a project eager to file and create new project. The most common way that are created Project is by right clicking on Projects Folder and click it New project. Here comes the core of creating your project. You need a select Java, which is what we'll be working with once upon selecting Java your represented with four options. The option that we used to create Java programs is job application because we create Java applications so we could either double click on this or click next. Once we have done this will be presented with name and location, name and location is where we can name our project, and it'll tell us where our project will be stored. This is very useful for more advanced lessons when we discuss how to read from text files and so on, but as beginner or you really need to know is your project name. When it comes to naming a project, there are some naming conventions that you need to keep in mind. First or the name of your project should be in one land with no spaces, and each would must begin with an uppercase letter. So Onatopp in first project because you could see one land capital if capital P and we click finish. Once you have open your project, you should be presented with the Follow me. You will notice that my screen or look slightly different from yours. My coating screen, as you can see here, is darkened for your benefit. The reason. It is dark and it's so that way I can show you the latrine without it harming your hours stock What backgrounds can be acquired. Joining two division solve created a dark looks a feel theme here through a plug in which I'll show you just now, which changes all of the curd to a more visually pleasing experience. As you can see here, I've also in large of the code so you could see it a bit better. But what you should really be seen is pure what, and you see the same curt, but in different colors. If you want to get the same plug in that I'm using, you simply go to tools. You gotta plug ins. You go to available plug ins. And the name of this theme is Doc, Look and feel things. You see the plug in over here, simply check the box and click in store. I've already install it and I've localized it to this page years so that we can have a dark enough to see. But that being said now, let's have a look of what we've created. As you could see in the Projects folder, we have now created a project, the job of project symbolized by a cup of java. We're so spec edges which contains our first project, which contains the class the class being What do you see here? Notice if I close it and double click here again. It opens up the class. The libraries contained the pre installed files J T. K 1.8 which the default, as you can see. But what we need to really focus on is the class that we've created. This is our main class. How we know it is our main classes from the following line. Public static void main. This is our public class. Here's our main method. Simple as that. First, let me ease what we have in front of us so we could make it more simple to break down. First you see these blue lands here. The's brew lands are known as comets. Comments are very important when it comes to coding because these leave little messages for any program is to check your coat. However, they are not necessary these default ones. So we simply remove them like so the one which I will keep you for educational purposes, Seen as you are a beginner. Is this one that to do code application logic here? This comment is simply saying you're Koerting begins beneath this land, which in fact is trip. Now let's break down the three Lance A. Previa we have package for his project, which is correct. Here it is. This is the package. As you could see it symbolized by a package and its first project closed with semi colon. You'll notice that a lot of the lands of code that we're gonna be writing will end in a semi colonel. Be that this is May. Let's move on to the 2nd 1 public class first project, which is the name of the class, which is here first project, and it opens up a set of cold brackets, meaning what it follows inside these cold brackets is what the code is contained in. As you could see, it's contained within the public class with these girl brackets, which start here. And as you could see, it highlights the next one closes here. So anything in between years the code that will be using and finally we have the public static avoid main. This is what is known as a main method. The main mace it contained within a class contains the code which will run when you run your program. So we have a main method, and the main method was to contain code the code where we'll be writing in between these two sets between the sit off cool brackets, as you could see highlighted here in the green. None of this is very important to what you need to know for now, but these three lines of code are very, very necessary, and your program will not work without put that out of the way. What we're gonna do now is Roger first line of code, the first line of code. Any program Arad's is our Portland outputs. A string string being a line of text. That's a little bit of Jog, and we'll go over in the next Listen, But I put the string and the string will say, Hello, world. You may have heard of this land. It is quite famous for programmers. This is the first line of code that any programmer rots. And it's infect saying programmers to create a program that says Hello, Yeah, put the string. We create what is known as an output cooked. This output line of curd will output a result. This is what the code looks like. System ducked out because we want the system to output and we simply top in print. L in and we have a sit off brackets closed with semi colon. I did say that we do close many of our code with a semi column now, within the state of brackets, we put in double quotations notice they automatically create a second double quotations and with image Will Raj what we want to say Hello. Well, was that we have written our first line of code breaking it down XY system out print l in set of records. Hello, world close of the semi colon. First, I'm gonna run this program so you could see what it does. You simply run about clicking on the screen. Battle pressing six. Once you've done this, your personal begin to run. And as you could see, it outputs a result. Hello, world. And it has a long way, Sicher. That's pre programmed into the i d to say your build was successful and it did it in Syria . Seconds, whatever time it takes. And that is your first line of good. Very simple. And it outputs would every want, for example, you can have your program say hello to you such as Hello, Joe. When the program. Hello, Joe. Now, before we in this listen, I'll show you a little addition to this output line. First of all, l n stands for Lan. This means when you've printed this text A via it'll start a fresh line and continue whatever's left afterwards says you could see here we have build successful below. Hello, Joe. But if we moved in and save rerun out program. One small build successful has now been clipped onto the end because we didn't start a new life starting line again, gently topping Alien rerun the program and it's back to normal and finally, on a short cut. Since this land is so common, they created a quick, rocky be simply topping is O. U T. And by pressing tab, it'll quickly right out the system. A print line once ball straight away for you is out, and any click tap is apt tab. Like sir, feel free to experiment with this before we start the next listen by adding more system our programs below each other or system out. LAN also start prints with different words to see what happens. That being said, that concludes this. Listen. In the next video, we'll learn what street needs are and what interviews are 4. Strings and Integers: Hello and welcome to your basic Java programming course with net beans in this Listen, we're gonna learn about three things. First, what our daughter tops in variables, but a string daughter tops. And why don't interject daughter tops. First, let me explain the difference between a variable and a daughter. Top variable is a container. A variable can come in many daughter tops and, as such thes, different daughter Top variables can contain these different daughter tops and nothing else . This means that variables are just containers, but daughter tops our tops off values the tops of areas. You can receive our strings in Tages doubles buildings. These are some more complex daughter tops. We'll talk about later in the course. For now, we're just talking about two strings and images. It's another to in order. Variable daughter Top is strings and images is the next logical step. Strings are text, their lines of text. They can be one character during infinite amount of characters. Diesel strengths. All these are contained within double quotations like we learned in the previous listen when we created our first line of could we had put to the line of text that said hello world. That was, in fact, a strength. And what is an integer and images just like it is? And mathematics. It ranges from negative infinity to positive infinity of numbers. It does not include decimal point numbers. So I don't think negative 1.5 or 1.5. Just think negative 10123 And so on. Where that means said, what we're gonna learn in this lesson is how to create string and interview variables. These containers will contain values. First things first, let's create a string variable the most basic to create a string variable one must simply top in string of the capital is and we must name our container. I'm gonna cool with contain his name, name closed with a semi colon. Just like that, we've created a variable more specifically a string one, a string variable which may contain a string value and to give it the value we simply topping the name of the variable equals And now we give the string value that say so. Notice We have double quotations. This is how we take a string. Valium Put it in a variable. If we had to move this were simply adding another variable name to name, which wouldn't make any sense. So I encapsulated in double quotations. So the program knows that this is the string value of John being placed in name now Are we here? Let's go over some naming conventions to be a variables. Variables are like that of your project. They are no space is allowed in some languages. They will have an underscore between words. However, in Java, most commonly you will not. Instead, you'll have the first word in lower case, and the second and third and so onwards will be with an upper case later to start. So if I wanted to create a variable of two words in it, let's say my name. We need to replace it here as well. You'll see that I have lower case aim at the beginning, but in upper case in with the next would a few other rules. You don't use special characters such as hashtags and and symbols, and you don't use numbers, or at least not at the beginning. You can use numbers after that is completely fun. That being said, those are some naming conventions. When it comes to variables just keep them in mind. Keep the simple description. Are QC and Lower Case later the beginning, then uppercase later. So on and you'll be absolutely found with variable names. But now what we've done years Greatest drink, variable. We've given it a very of John and if we wanted to, we can put this valley as well creating a output line. But instead of double quotations, John, I'm gonna put in my name. I'm calling the variable. During the system are print line to go back into the system, found a variable my name, locate the valley, and I put the value. So now whenever we run, the program outputs junk As you can see here, a programme is successful. If we wanted a shortness, we'd simply change this salon and combine it of this land. Yeah, well, we created string. My name, as you concede, is an era because the program knows that there is no value with mining it. Well, let's give it a very now in the same non by simply adding equals afterwards. And John just like that. So now still works the same way. If I run the program again and outputs jump if I wanted to create more string variables. I can do that. Sticking your name equals Brian, plus a semi colon. That is perfectly fun. If you wanted to add them with my output, I've simply add a plus symbol in my bloodline and put in a new name. Now you may know to some problems here. When I run the code, it commands him. John Ryan doesn't seem run. So what we do is we add a new string valley. In between, I would say a wide space. So plus devil quotations space in the reputations, plus again new name. We run the program. John Ryan. It's simple building blocks that were just putting together nothing too serious. But again, we can shorten it. One small. We take away this long and we can end the instead she ation of new name with its in a civilization as well. So I just add comma after John Yah and putting you name equals Ryan. It works the same way as if we building a list in a perfect English language. We just had a comma afterwards, and we had the new value, and we can do this. On was until infinity but let's a stick of thes two names taste. Our program looks the same way. Now. That was a little bit fast, but this is all just simple practice and putting these things together. What we do is great. These programs, we simplify them, make them more efficient. We've done just now. If we had done it with the same way we did at the beginning, we create the variable. We give it the value we create another variable. We give it another value, and then we are put it with another system up front line and then another system or print line. And soon will I have a paragraph of code when it could simply be done in two lands like so . This is just the benefit of the small techniques. So just remember, if you want to add strings inside yard, put, you simply add a plus, or, if you wanna add them inside here, you can also give it. Another plus is well, that works just fine as well. As long as it's a string, you can put anything that isn't a string inside a string. It just doesn't fit. That being said, these are strings and This is how you work with them when you are putting them great to them and giving them values Was that being said, we're not done of strings? For now, let's move on to inter Jizz. So I'm going to raise these two lands and started to beginning Introduce a far more complex and will be working off the mathematics in the next Listen for now, you just need an Arctic rate, an integer variable, which is this follows into We give it a name like we were to string variable so numb equals and we can give it a value of five flows of a scene economy. Nothing complicated at all, no different from where we created a string. Except now we're giving it a value of staff were not encapsulating is in double quotations cause it's not a string. We're just giving the pure value of far to this number. And if we wanted adequate it, we could do just that like you see here and there you have it string and integer variables working between the two daughter tops and the next list. And we'll be focusing more on this interview variable that we've created here, giving it different tops of operators to work with each other, such as addition, subtraction, division, multiplication and so on. For now, that concludes, is listen and I'll see you then. 5. Mathematics with Integer Variables: Hello and welcome to your basic Java programming course with net beans in this. Listen, we're gonna be taking a look at mathematics with integer values and variables in the previous listen, we touched upon very lightly on indigenous. We learned how to create, um values, and I put them now we're gonna work of them together. We did this of strings. Now we begin his images, but they're far more complexities to it. First of all, when our dressing, mathematics and mathematics really does deserve a lesson of its own in this course. So let's go over some basic mathematics. We have no Mia And when we run the program, it outputs the valley off half, as you can see. Yeah. Now we can use plus and minus with these things as well, so we can have bless double quotations, had a string, and I put that's no different from anything else. But if we were to add instead of a string to it and we add another five and run a program and outputs team when you have an operator between two inter jizz, it immediately knows that this is mathematics five plus five. Nothing complex. The program reads it is that it adds them together at outputs, a result which is 10 very, very simple. If you want to to print five and five together, you would simply plus double quotations, but nothing in it. And when you run the program, you got five and five. That's because it registers this string of you between the two. It doesn't register them together, but let's remove that for now and just focus on the operators. So we have five plus five, which will run. We get 10. We're Sigit subjection, which is just madness like So we're signature division, which is the forward Slash. Divided by five is one and the way of multiplication, which is the gastric symbol or shift eight. If you don't know on the keyboard and you get 25 very, very basic operators and very useful to have when working with basic mathematics in your program. He's also help you to keep count of certain things which your discovered later in the course. But for now, this is just the simple mathematics with these variables, which shows in it is that these variables follow the meth Med principles of blood mess will be odd mast opinion. Which level of education you on? In other words, brackets come before everything. So if I would have Racketeer Plus and I have another set of records numb, divided by number, the brackets would work the same way. So let's do these quickly. Five times off. 25 five. Divide above one 25 plus 1 26 So if we run the program, indeed, get 26 it doesn't work from left to rot. It's a simple is that you were counter more mathematics later course, but these are the important pieces that you just need to take note off here again, I would recommend some experimentation with the mathematics of interview variables. The's can be done and other variables, for example, to create another one on a great number that will be. And I could do mathematics with the DEA, such as numb minus 10 close of a semi colon, and I could use it later in this hour. Put like so So let's see no us what we should get. Zero, which we do indeed, negative five plus five that another thing you should note about the interview variables is the division. When it comes to the other three, You don't really have to worry about it so much better with division. You may get what is known as a double a double being decimal numbers. We'll cover that later for now in the interview. If we had to divide something and it wouldn't give us a dismal place, it would round it off. So if I have now, let's see. I have my thought. But I want to the divided by six so numb about about six, it would be zero. We're on our program. We get zero now. Let's develop a full four does, indeed, going there once, but it is a little bit left over. Run a program. It goes to one. It runs it off to however many values you could you can get. It will ignore any remainder, no matter what. So if we had 20 and we want to do divided by 18 we'd have to lift over still one and will continue to be one. Even if it's a living, you still get one. If it's 10 you'll get your to the whole number. It makes sense as well. But if you're looking for decimal place numbers of vintages, you're not gonna find them. He's a very basic numbers ranging from negative infinity deposited affinity like you would with any other mathematics. Anyway, that's all you need to know. When it comes to inter GIs and mathematic operators, we'll touch upon more mathematics later on when we start working of doubles. For now, they're concludes this. Listen. In the next video, we'll be taking a look at an if statement. 6. If Statements: Hello and welcome to your basic job of programming course with nit beans in this. Listen, we're gonna be taking a look at the if statement. Now, the if statement is going to cover a lot of important content when it comes to Java programming. So make sure to get comfortable for this. Listen, because it is going to take a little bit longer. The first things first, I'm gonna tell you what if statement does what an if statement does, is similar to that off a class and has a set of gold records like So what's in this court? Records contains conditional cut, meaning this could will run depending on if a condition proves true or false. Now let's take a note at this condition. What kind of conditions are we talking about? Well, let's say we want to a certain variable to be a certain very, for example, we create an interview available. We want to very to be far. If it is not far, we don't want to cut to run. If it is far, we do want the Kudrin. So depending on whatever happens, new program before When it comes to this, if statement and that none variable is not equal to five. The code will not run. And if it is, it will. This is conditional code. It's just comparing two valleys with each other. I'm gonna show you how to do that right now. By first creating any statement first, I'm gonna create this hypothetical interview available into numb equals, like so, No. Okay, if statement gonna create a sit off brackets and a set of cool Bracken's, this is the build of an if statement. Did you notice that it's hard to read because we don't have anything to compare it to right now? That's because we need putting numb, and now we need to compare it to a sick and venting. So we want to compare to five. What we need to do then is put in equals, equals, equals, equals like So now let's break this down a little bit wadded up to equal symbols. If I wanted to compare the two with each other, wouldn't happen equals no. In fact, putting the single equals means I'm changing a value to that. I could concede here when I created any teacher, I used one equal symbol. If onto these double equals. It would be a very different result. And it could be areas in this program. But I want to compare number 25 Islamic go too far. It is, indeed. How do we know for sure? Well, we have to run the program. But first, let's great code that will run. So we know. So yes, it vehicles laugh now we is the programmer already know that number equals five. But now the if statement is gonna check is not me. Go five. We run the program and the output is yes, it equals five. So our program works. We contested out further. We can change it to another number. Negative Off is not equal to negative. Five were in the program. Nothing happens. So the code didn't run. The if statement worked in reading the code. This is what is known is conditional. Cut Rickard. That's within. If statement did not run because the condition was not met. Very, very useful. Does this work only with equals equals? No. We can work with other mathematical operators that we've worked with in school before, so we have negative five. So how do we make this program run? But still use the same values. Number five. Well, how about listening? If numb, it is less than five world run the card. So let's just erase this message to make it say yes, it runs. So I ran the program. We do know Negative Farm is less than half and says Yes, the program runs. If I was to change the to greater than five, which it is not run the program. Nothing happens, but I change it from negative 5 to 50. Now I rerun the program, and the programs is yes. Now you're starting to get the idea of how this condition operator works. If certain requirements will be, admit, the code will run. So let's take a closer look at these operators we've covered, equals, equals, recovered less than recovered greater than we consider. You created an unequal to meeting that it can be great to them as you could see what can be equal to, As you can see, four. Run the program. Nothing happens on the same with less than and equal to now for the program it works, and if I change the ready to cough, it still works. So those are some of praise Let's take a look at one more operator before we in this. Listen, we have equals equals that less than equals. Better than equals have greater than we have listing Now what happens if we want something to not to equal something, meaning our program will run as long as numb does not equal five? Well, we have the exclamation point equals This is not equals. So right now the program will not right. It does equal five. If I get for it, runs if I go six. It runs. If we do anything else, and as long as it's not far, code will run. This is an if statement conditional. Operators are very much important when it comes to be working with users. As you'll find later on. It's statements can be infinitely complex, and as such, weekend also counter many problems. If we don't use them properly, for example, I want to create a program that says yes or no. I don't want that just says yes or presents me of blank. I want to have a yes or no. So let's say we create an age program where a person needs to be 18 or over to watch a movie, so you have to make sure nothing is greater than or equal to 18. But we now need to create another if statement that works opposite. So no is listening 18. And instead of yes, we print now next. Currently they uses Age of six, which means they are not permitted to see the movie. But if they were 18 they are committed. If they were older and gently definitely permitted. Yes, so it isn't that difficult to understand. Bay of Statements can be incredibly useful, and they contain very important piece of code. Now, before we move on to the next Listen, I would like to highlight what exactly is happening in these operators. What is returning in these operators is not a yes or no. It is, in fact, true or false. It's literally the value. True or false, true or false belongs to your daughter. Top man is building. Billions are true and false. They contain true or false Oh no, those are the three values we'll work of to, meaning we can have an if statement here that runs on just a single value. We don't even need to have an operator. We just need to have a body. By using these operators, we create a value that is true. But if we created a 1,000,000,000 variable, like so simply topping billing, physical test equals and we will give it the value of true well, the value of false. So I'm gonna make the coat simple. And I'm just gonna put in a test like so I run the program. Nothing happens. But if a change tests value to troop, it says yes, very curious. So we can use billings variables so we can use building variables to work with. And since the operators we created before was there greater than and equal twos and so on, if they returned a building, can we do the same thing to put a 1,000,000,000 value in a building variable? We can indeed recently put in number. He's created them. Fuck this, but definitely right now it's 120. So the value should be true. 120 is greater than five. So this if statement should run the code, it does indeed, if I change it to list in which it is not, it doesn't run. So now you see how the operators work. It's not similar to us creating a variable but giving it a value later on instead of in the same line. So what we doing really is copying this line of code here and putting it in this if statement instead of creating a 1,000,000,000 variable at all, which really isn't necessary? We're saving ourselves lines we could right at the beginning. Anyway, that is enough of this. If statement and that is the Boolean variables, lots of heavy content. It does require a lot of practice, but we're really just gained start of the if statement in the next. Listen, we're handle more advanced operators and nested if statements see you, then. 7. If Statements and Additional Operators: hello and welcome to your basic Java programming course with Nick Beans in this. Listen, we're gonna be taking a look. Administrative statements, additional operators and if else statement, First of all, let's taken out of this program are created in the previous listen in this programme. We haven't age and we're going to see if the age is greater than or you go to 18 in which case we print. Yes, but if it's under 18 we print no, a very simple Bergen. When I run it, it'll print yes, because the age currently is 25. But if I printed 15 good print, no, simple as that. But I can make it simpler, are using an if else statement. And if else statement works kind of the same way, except it has a default condition. If the first condition in the if statement is not Mitt, you can create an else at in off if statement like sir but simply topping it else. A new set of double brackets and that's it. You can copy this line of code AEA, paste it here and get rid of this if statement entirely. And that works the same way. If I go back to 25 run the program says yes, but if I go back to 15 it says No, the if else statement, very simple. And it'll help save your town from creating really unnecessary if statements and it looks much better as well, Far more organized. Was that sit? We're now going to take a look at Mr Tive statements, Mr. If statements simply put our if statements within if statements. So what I'm gonna do is create a program that investigative statement can solve. I want to create a program that checks to see if a number is between 25 30 inclusive of both 25 30 in which case I would need to use initiative statement because they are too operations anything can look for. Then I need to make sure the number is greater than unequal train far, but I also need to make sure it's less than and equal to 30. Send it statement within, in if statement and it looks as follows. So here I have the program. Right now, when I run the program, nothing will happen because the first condition is not even being made. Nothing but Now let's say I want to have the first condition Mitt put in 50. It is indeed greater than 25 but it's not less than we go to 30. Run the program. Still, nothing happens. So two conditions to need to be met. Indeed, I meet the first condition, so this code will run, but I don't need the sick and condition. So this code here Montrone. So let's meet the conditions both now 25 it says yes. If a city it says yes. If I say any other number between 25 30 such as 27 it will say it will say yes. Very simple. Mystery of statements have many uses throughout many programs, but this program can be made better with an additional operator. Now, before I show you how to use this additional operator, just know that missed it. If statements and addition operators each have their own purpose, respectively, there are some programs better suited of, in addition, operator and there some better suited within the study of statement. So don't try to use one over the other. Try to use the one that was comfortable. Well, the one that's better for the situation. This helps indeed create much better program and far more efficiently as well. So this is how I was simplified with. In addition, Operator, I'm gonna take this condition ongoing included here within this if statement now, I'm not gonna include it happening, comma. And then pasting it be it doesn't work that way. It isn't way you create a string, it actually requires special symbols, not an actual comer. So I'm gonna race thes Lancia properly indented like sir, and to end the operator to this, I simply put two and symbols and I face today there we have a two conditions that need to be met and the and symbols simply means just that. And if numbers greater than and equal to 25 and now obviously sending equal a city, it meets the conditions right now. So the program does indeed run. If I was to go higher than 30 however such as 31 it would not run. If I go lists such as 24 it would not run. That's the complexity off having additional operators. However, let's throw in some redundancy by using the next additional Breda the all symbol. If there's an end his ozone, or your symbols are two vertical lands or shift backslash, and what the all simply means is only two conditions on the other side of the or need to be met, either. None greater than equal 25 needs to be mental. Number less than and equal. 30 needs to be made, and this is what you see. The redundancy. This means any number goes. I can have 2000 400 run the program. It still works because it meets the first condition. I could have negative 2400. It's still wicks because it meets the second condition. Well, I can simply have 27 which weeks? Both conditions, but that as a matter, because only one is necessary. And there you have it. The if else statement the nested if statement. In addition operators, when it comes to if else statements, there's really not much else in you. Add to it you can't continually add else is beneath each other by simply saying else if else if else if but in this case it will be far better to use an additional operator instead of that, so you have your if else you have your additional pretties. Any administrative statements I would recommend practicing of initiative statements and additional operators more so These are more complex, and as such I think more practice is required. That being said, that leaves us off with the if statement. We're not finished covering this very important piece of curd, and we really didn't move onto new content and the next listen, we'll be learning about the wild. 8. The While Loop: Hello and welcome to your basic Java programming course with net means in this. Listen, we're gonna be taking a look at the while loop the while loop is, as it is says in the name. It is a loop like an if statement to contains a set of cold brackets that contains code and again like an if statement before then and has the parentheses with the condition. If the condition is met, the code will run. What makes it a loop is as long as the condition is constantly being met, the loophole run over and over and over, repeating the code within. And as such, we can create while loops that are run as many times as we would luck an infinite amount of times until we say stop. Want all certain numbers, Mitt, What we're gonna do now is create a very basic while loop with a number that needs to be met, in which case we're gonna have a counting variable accounting variables. A simple interview available bet with each run of the loop, it's valuable. Increased by one. I'm gonna show you how this works now. First, I'll create the country variable quote count equals zero. Now I want to create a while loop, lacking a statement at home in while with the parentheses inside the parentheses. I have a condition that needs to be met. So for now, I want to make sure that the loop will run five times. So while count is less than I thought, the reason I'm saying less than instead of less than and equals to this because Countess, currently at zero and not add one if it was that one, I would say less than and equals two for our leaders is pretty sort of girl brackets with the coat grade system or print line that simply prince counts. Very. Now, what I'm gonna do is run the program straight away, just like it is right now. And, you know, notice a problem. Start running the program. It's continually printing. Zero keeps going and going and going rerunning the loop over and over and over again until we click this red square here which stopped the program as the sea build has been stopped. Total time, 16 seconds. So for 16 seconds, hundreds of zeros had been printed. So what we're gonna do to fix this program is use an incremental An incremental is a simple line of code, which adds 12 counts value. You can do this. Either way. You can do this mathematically come equals count. Plus one makes sense. Count when I have a new, very its value plus one, and this will run. And true enough, if you run this program, it'll work just the same notice. Five Values The code ran five times. No are lib runs five times, but a common way to increment a interject is simply camped plus plus. And if a semi colon from the program, the result is the same. It looks for Nita as well. I would recommend using complex Plus instead. Another beauty of the world is that it works like an if statement in the way that it uses a beauty value. We're simply creating another condition. If we were to put true in here and without changing it, Edward Warren forever like it did before. Example True Brendan Program and again notice. Now it's counting up so we could see how many times is counting of this camp plus plus until we stop the program and the program has stopped after nine seconds, and in that time the loop has run a little over 150,000 times. So you see, loops are very powerful. Imagine if we were to add one with each new land. In other words, we saved ourselves of 150,000 lines of code are simply just using a loop. The while loop is not the most commonly piper. The while it is only one of the two loops that will be learning. But the wild has many uses above that of the next one, and vice versa. I recommend practicing using a while loop from now, but mostly with counting variable. Since we haven't learned how to change the values off 1,000,000,000 values or your strings , for example, for now that concludes this. Listen. In the next video, we'll be taking a look at a special kind of love. The following 9. The For Loop: Hello and welcome to your basic job program. Nichols with net beans in this. Listen, we're gonna be taking a look at the full lip. Now. The previous listen, we covered the basic civil while. Look what it takes to make. The LeBron wouldn't make what it takes for the loop to stop. Now, what we're gonna do is create a full loop or four lip works just like a while, Ip in the way that it has account variable, but not in the way that eight years is really as such. A full up with a quite different to that of a while. So it will be four. We'll create a set of parentheses. We'll create a set of gold brackets, which we can have a output if we're luck, such as hello. However, what is in the parentheses is what is different inside the parentheses will create account variable. We will create an operator condition to work with and real increments that comfortable the full. It looks as follows int and we create any available. I just a common full loop counter available equals zero. You put Cindy Colon, I and now this is where you put the condition is they spend far another cynical on I plus plus. And that's it. It has three parts separated by semi colons that has us creating our integer. I equals Zero but has us with the conditional operator eyes list, then five and I plus plus. So it looks similar to that of a while. Loop with the counter variable, but it's all bunched up into one place. So if you're thinking about years in the wild lip that's mainly using account, I would strongly recommend using a full live instead. That being said, let's run out her again and a prince and look five times fairly simple, and we can have it work backwards if we're too far. This created an zero. I'm on this finals run. The program again runs five times, just reversing things. The for loop is very simple and at the same time very useful. It can be the most commonly used for loop, but it also is sometimes not the best. Flutie's in a situation when it comes to be working with most daughter, you're most likely these in a while lip because you'll be comparing different doctor if using a loop that needs to run a specific amount of times that you said I would really recommend using a for loop. It saves you a lot of time than creating a while. Loop of contrary born everything. It's all in one line, very neat and very efficient. There's nothing too much to add to a form you can create. Four groups within four looks like in the study of statement, and the same could be said about the while. Lip. The four lip just works like everything else, quite efficiently and very well when it comes to be working with repeatable could. That really doesn't matter too much about what the daughter is. It's just about running the code. I would make him in practicing with the for loop a bit, but it should take less practice than it does take with a wild scene, as you only have to concern yourself with the conditional counter variable. That being said that concludes is listen. In the next video, we'll be taking a look at how to get user input. See you then 10. Retrieving User Input: Hello and welcome to your basic Java programming calls with net beans in this. Listen, we're gonna be taking a look at user input Now use the import It goes without saying is the bread and butter of most applications. You require user input, be it through daughter through controls. This is all the core fundamentals of programming. You're designing applications for the user to use. That being said, user input is definitely important. So how do we get user input in Java? Well, the code is fairly simple. We need to do something different than what we've been doing. We need to import a package. More specifically, we importing a package that contains the code that we need to ask for uses input. How do we import a package into our Java program? Well, follow along. First things first, you go through just below package. It's project any top in the following import Java X, which is the name of the package. Don't swing anything, etc. Docked and now it water generates a list of what I can import. There are many different things we can import, but some of them we won't be needing some of them. We will be needing in this case, most of them we want to be needing. But to save our lands have could It is much easier to simply top districts, which means it will import everything within the package. And we can use it to our advantage close of the semi colon. And that's it, you know, Have the required could to get use input? Well, you need to do know is create a variable for the user to import into. Not typically, when it comes to the code that we used to air get user input, it will need to be a strength, a lot of text if we want to do any other daughter Tops would need to convert it. The reason being that the curve that we used to get used input outputs a string, so we need to have a string variable to input into other was we are gonna have a clash in the program. So what do we do? Well, that will be handled in another Listen for now, we just need address, one important thing, and that's getting the user input itself. So let's great. The string variable that they used was important, too so I'm gonna create a simple program with the user. Must maintain the name. So I named a variable name equals. And now this is where we use the code to get his input. J o Capital. Other lower case, P J option Pain Capital P Don't show input. Dia. Look, we put in a set off print disease close with semi colons. Now that that is done, we just need to have a message for the user. So what I'm putting here and this parentheses isn't what I'm putting in the string. It's what I'm sure in the user in a little box. So if I want to use it into the name, I'll say in tow your name now if I ran the program, As you can see, there's an input box. It is a question mark because it is asking us to fill in something and into your name, just as we designed and are. We ain't in. What if we wish I could be John, but for now, that means nothing because we don't have any additional code. So we can't see if it is actually importing into John. So it's great an output line. Let's create name. Let's rerun the program will small anything. John and John is out. Put it. It's our program. Works were not able to retrieve these input, so that's a really simple program very similar to that are entering an online chat room, a big plus as into the lobby. Now we have a suitable message to go with it. John John has into the lobby. Achieving user input isn't too complex, but what happens if we want to put in a number? So let's put in a number of our making Islam first and training program, and I'm gonna put it five. It has five correct, but is it a five week of work with? Well, let's add five in the output from the line of code again. Up around five, it puts 55 That's because we put far into a string, so just reads it as the text vision off up rather than the inter division, so there's nothing we can do with it. We do need to converted into an integer because we can't simply have used the input. When we can only get one kind of import, we need to have any important old daughter tops, and we need to be able to convert it with necessary. So now it's the conversions that we're gonna trace for the rest of the course till the project converting daughter tops to each other is very important, as you'll soon discover. And that is what we will govern the next. Listen, I'll see you then. 11. String and Integer Parsing: hello and welcome to your basic Java programming course with neck beans in this. Listen, we're gonna learn how to convert different daughter tops into Yala. More specifically, string and interview data tops. First things first, you'll notice that I've imported Jobbik swing. That's because we're gonna be using it in this lesson as well. And also, you need to know what is converting in programming. To say converting is the right name is isn't a great idea. The more common jargon term we use when changing a different daughter top into another, such as a string into it in future, we need to join to string is called passing. We pass it p a r S e and that's what we're going to learn how to do now in this listen and there's no better way to do it Then, starting beginning with the string, I'm gonna call it test text equals and of double quotations. I'm gonna give it the value of our closer, the semi colon. The reason I give it the value of farmers because we're going to convert it to an integer. And if we used text, what would get is a mister program either through an era or be through using the hidden number terms that we used place letters and characters. So to be safe, we're gonna be putting an integer in this test text, and we're now converted it to an interview. Now, how do we do that? Well, that's great. An inter Juve able and no equals. Now we can't just simply put taste text. Okay, you notice an error is formed because we're trying to put a string into an inter church, but there is a way we can pass it. So raising this Lenya, we top in the following interview docked kos and a set of brain disease, and I'm gonna put test text within the parentheses, locks up. That's all you need to do. That's how you convert a string into ninja job. So it's tested up. I'm gonna take this up with lung number thus far. Now, if it works, it should print out 10. If it doesn't work, it should print out PowerPoint off. So let's run the program ended outputs 10. That's it is simply converted by tapping interject dark past, sent and putting in the string that you wanna convert. So we've learned how to convert a string into an integer one was simply surround about this so we could do this now with use input. So I'm gonna raise this line of code here, and it's still taste text. I'm gonna be putting in J option J option pain that show input dialogue into a number no areas. Everything is in order. Let us run the program. And I'm gonna aunt in 23. So tradespeople swap it should are put a 28 which it does. There you have it. That's how you couldn't get your using input If you want to put a number now, we need to convert a Inter June to a string. Now, this process is a lot more simple. One must simply first create a integer So I'm gonna created a vent Eagles part Now we're gonna have string taste, text, equal number again. This recalls an era. And if that being said, we also don't write what you might expect, which is string that passed string like So this is in Krekar work. So how do we convert uninjured digits? String. Well, it's actually a lot simpler. You put in double quotations, but nothing inside. Plus No, that's it. You converted by simply adding it to another string. Text was automatically converted to string and you imported into string text, text. And now I first job put it with test text less far and run the program. It's his far pop. So we succeeded. We've converted an inter Jane to a string. Nothing too advanced that when it comes to be converting a string into an interview, you do need to use a interdigital pass end if you use this refusing input as well. Another daughter you should be absolutely fun with that said that I could bring intra jest to string and vice versa in the next. Listen, we're gonna learn about in your daughter top as well as its Parsi. I'll see you then. 12. Character Data Type and Parsing: Hello and welcome to your basic Java programming course with Nick Beans. In this Listen, we're gonna learn about a new daughter. Top the character daughter top and the way we can pass it into string an intern? Vast versa. So first things first. What is the character daughter top? Well, it says the name. And plus it's a daughter top that can contain a character. More specifically, this character can be a number. It could be a special character, and it can be a letter. But the specific thing about HR variable, as it's commonly known, is that it can only contain one, one single character. You create a character level simply topping char, given a name such as test or commonly, CH equals, and you put in single quotation marks now and stay of double quotation, and he put in a letter such as H Close, the cynical. Now this doesn't have to be ages convenient. Later can be any other character. Can you be any other number? It's a suppose that the character of Able is normally used to contain small amounts of daughter and again very useful. If you only need a single character that being said. Let's figure out how to convert this now into other daughter tops first to convert it into a string is simple. We created string. Yeah, equals. And it's the same way we did with the interject double rotations plus ch cynical. That's it. Although it really is unnecessary. Seen as C. H s a kind of acts like a street, so you don't have to worry too much about the complexities. Now, how about ch to an institute? Well, this is done as follows Ain't numb, equals integer got us. And now one does not simply add in ch the Sosa cause a problem. So what we do is we in the moment converted to a string as well? So added to double quotations? It's now immediately translated into his string, and our is simply converting a string which we really know how to do. And there you have it. That is, I convert a child into a string or literature. Now, how do we convert a number and a string back into a jar? Variable? Well, that is a little bit more complex. First things first, I'm going to create a string stream. Good word equals and I'm gonna give it a word such as? Hello, Closer the semi Kona. Now this isn't a single. Characters are Harkey. We converted into a chart. We use a special method. When it comes to this, we top in the following first chars pH equals and out. We're going to use the miss. It called Char it char act allows us to select a specific character from a string, automatically converted into a character and store it within a character variable. To use this myth, it was simply tapping the name off the string. We want to convert. Don't char at they said to parentheses Composer The semi colon. Now, within the current disease, we include a number this number refers to which ever characters in the place of a string. Right now, zero refers to the 1st 1 which is H If we want to take the letter h from the string and put it in charge, We simply there and we could taste it out. Button up. What? Lana, And let's put a C h. If I run the program, it'd up, put the letter H and it would run on words. So if I want you to take the E. It would work the same way. I did not get e to get a l three are given ill and full. I'd get a no nothing too complex. It doesn't. It does take some practice and getting used to when it comes to working of char, especially the try admitted. But this is I covet a string now to chop. No. What about a number more number works the same way as we with all strings into numb equals far And what we simply do is converted on the spot. How we do this is as follows We create a set of brackets. We have our double quotations plus now automatically Regis converted it again to history and we used char it to now find a place in the string. Of course, when doing so, be better to put zero to start. So four and the per gram I get five So they have it. That is the character daughter top and how to convert it to string an integer and glass versa. In the next lesson, we tackle the last daughter top for this goes and that is the double daughter time, which I did mention in the mathematics of interview variables. Listen, that being sit, I'll see you in the next video 13. Double Data Type and Parsing: Hello and welcome to your basic Java per giving course with net beans in this. Listen, I'm gonna be introducing you to a new doctor. Top the double daughter top now, in a previous listen, When I worked of images and mathematics, I talked about there being a double daughter top. This is the daughter top that contains decimal points. Doubles can't become in negative and positive as well. And as such, they are more complex. Start atop than an interview. To create a double is as follows once and be tops in double. Is it a name such as Denham equals and value such as five point path. Fairly simple. It also used the same mathematic operators. So don't take it too different from inter jizz. They're just more process such as Denham Times five Yet more specific numbers 27.5 And of course, division works on it as well as you can see here. So that is the double not too different from that of an integer and easily to work with. It creates more process results. It looks more professional. I would recommend using it when you're working of more precise daughter. That being seemed Let's look at the conversions. What we're gonna do is convert double, do the other dollar tops we've worked with first a string your string. It is no different than when we converted an Inter Joe. We put in double quotations less, you know, And there you haven't simple conversion for char again. It's no different trauma CH equals, said two brackets Devil quotations less Denham, the char at zero bent with these two being only owns that very similar to that of an inter chur when converting it to enter J. You do work with it slightly differently instead of doing interview Pass. Isn't we simply tapped in, um, equals, and we put any city grant disease with mint in it. This is what is known as a quick pass you put in the name of the double, and there you have it, and this should around it off quite nicely if you put numb now, program that outputs five and this works and still ignores the remainder, as the interview often does, even if it's Farpoint non, it doesn't have it. A six fairly simple. Converting the double to string and char with Inter J. You do it slightly differently. But again, nothing. A little practice conflicts. And now let's convert it the other way to raise these lands. Greatest ring. We're equals opened. Five Presidency me, Colonel, what do you do then? To convert it into a double is similar to that of an interview. So equals double pass, and he put the string inside. And as you can see, if I put Denham plus it should be 10.5, which it is indeed. What about a child? Well, a charge similar. No. So let's go. We create this line here. Char ch equals five. Yes, we can indeed convert this to a double as well, Our first draining into a strength like so What we should now get is 10 10.0. Since we can't put in the full double as in a five point something or whatever, we can only use one character. We only presented with one number that commanders will just be an integer. That being said, converting a charge of double again is nothing too serious. And finally converting an integer to double. It's just created interject int num equals 24. So double Denham equals No, that's it. When it comes to converting. Interested to a double. No conversion is necessary as you will see what I run this program that outputs 29.0. No double boss double no, converting it to a string. First, it is simply you place an interview into a double, and it works. Unlike when you place a double into an integer, and there you have it, the double daughter top and it's posses from the other daughter tops. The double is something that does require practice, especially when it comes to these conversions we've been doing in the past three videos. Passing comes in many shapes and forms, which is why it is quite handy, turbulent cheat sheet. Well, you can go to put things back. I do recommend writing it down, keeping it on hand when working with your basic projects, as this is a very handy tip to have, especially when you're working a different perhaps of daughter. That being said, this concludes the listen. In the next video, I'll be providing you with a discussion on the project for the schools in the discussion. I'll tell you what is required of you in the project. And don't worry the listen after that will be me, providing you with one way in which you can answer it. I'll see you then. 14. Project 1 Discussion: Hello and welcome to your basic Java programming course. And in this video, we're going to discuss the project for this course. For this project, you are to create a program called Ticket Tester. In this program, you gonna ask the user five terms to intend on age? You will then test this age to see if it is above 18 not inclusive 18. Each time that it is above 18 you keep count, and each time it's below you keep a separate count as each ages entered us, then print the age Kerlan space and then say with its entry or no entry, all of this must be done using two if statements and a while once the while loop has reached its limit off far your then to print out the results as follows. The number that are not allowed entry, the number that are large entry and in the final line you're to say the percentage of the testers that all our entry into the program do not worry. However, I am not throwing you into the deep end. Here are some tips to get started, you're to first create three inter jizz one that keeps count of the new entries, one that keeps count of the entries and 1/3 that keeps count for the wild off the turtle inside the wild. If you'll have 1/4 integer, this integer is the Agent UJA toe, which the user will be ending in their values. You will then have your if statements inside the wild and at the end of the wildly you're create three system our print loans that will print the final information a k a. The ones that are allowed entry. The ones are not allowed entry and the percentage of all the testers that are allowed entering into the program. 15. Project 2 Answer: Hello and welcome to your basic Java programming course with Nick beans in this. Listen, I'm gonna be fighting youth. One of the answers to this course is project. Before we begin, we need to create our project itself. So a new project? We wanted to be a job application, and we need a name. It a ticket Testa. As described in the previous video. Once we have done that, it is time to begin cutting. First thing we're gonna do is import the job X wing package because we are working. If you say input like, sir, once we have done that, we begin qwerty. But first, creating our three interview variables int no entry to keep count of harmony are not allowed entry and entry to keep count of how many do make it in. And finally just a normal comfortable like sir, Once we have done that, we're gonna move straight onto a while loop. And we wanted to run five times. So while count is less than five, like so Was that out of the way we know begin to us the user to contain an age so it creates an extra variable. Could age equals interject us. And now an input dialogue. And we awesome Tonto in the age into age to see give allowed entry a suitable message, and we're going to have 19 minimum just to let them know. Okay, we're turning back to occurred. We're gonna create an if statement to check each Good said if age this created an 18 we're gonna have a foot age us curl in space entry, same time births. We're going to add a value to entry because we want to keep count, and then we have an else, like so we can use to a of statements, but and else will do great. A suit of our put in once more age plus, except this time, no entry. And now we add one to know entries that you that should do it for the if statement. And now we just need a at 12 counts. Value maxim Was it out of the way? Who you can move on and to create a fun up puts That is really the call of our program. Nothing too complicated. And the outputs you'll see on a different other first will print uh, no in trees has described in the previous video, and we're gonna say that's where they are not allowed entry. Create a similar thing this time for entry are allowed entry. And finally, when you work out the percentage greatest of brackets, we can do this any mathematically wiles. But I'm just simply gonna take entry. Tom's 20 says we have five options that should work out the percentage Don't forget to add that presented symbol of tasters made it into the program that you do it and that should be a fun up. But I'm just gonna make the smaller so you can see it. But better. There we go. That's a bit better. Okay, As you can see, we have three into two variables we have our while a loop contained within is our input dialogue line like so within Evan. If statement to check the value of age and then we have our final outputs. Bologna. So let's taste on our program. I'm getting into in three ages that are lot entry. So 19 and higher. So I have seen 19 19 years. Entry 25. That's a lot entry. I'm gonna put one that's below Well, that's no entry again on on 80 entry and once more, another below 14. As you can see, it works correctly. 19. Entry 25 Entry 12. No entry 80. Entry 14. No entry and two are not a lot entry, which is correct. Three are lot entry, which is correct. 60% of testers made it into the program, which is correct. So there we have our program. The final output is correct and needs the standards, and the program does ALS that needs to. Now the question is, Were you able to create a program that had the same amount of Lanza's minded or less? It is possible to simplify this program in many different ways. For example, we can waste to lands creating these two here on separate lines. Or we can Ademir Entry equals zero comma count equals zero and a raise These bombs. This program can be simplified further and done even better with what you've learned throughout this course. If he had succeeded in creating a more efficient program thing, Congratulations. You have passed this test with flying colors. If you struggle to great the program on able to by creating program that didn't work, I had Moreland's curd and minded that I do recommend giving it another shot of what you have seen and seeing if you can make it even better. There are plenty of ways in which you can simplify this program. With that being said, that concludes this lesson and the scores in the next video, I'll be giving you a conclusion to what you have learned throughout this basic ALS. I'll see you then. 16. Introduction to Advanced Java with NetBeans: hello and welcome to Section one of advance programming with net beans. In this section, we will be discussing methods. Methods are small programs that could be called upon to change values or give new ones. For example, in my previous cause, we used the dot equals ignore case method, which was a small program built into jarba that allowed us to ignore the case off letters we will touch upon that method again, and many others. Methods share something similar to each other. They all have a variable dot the methods name and then, of course, closing with brackets. This may help you identify methods in the future. In this section, we will go through several methods that will no doubt aid you in the future. Too little programmers use methods, even though they are extremely useful. I hope you'll realize that as well. By the end of the section, in the next video, we'll learn our first method, the to upper case method 17. The toUpperCase Method: hello and welcome to your advanced Java programming course. And in this video, we're going to be discussing the to upper case method. Now, before we begin, let's first start by creating our project. Now, the more perceptive of you have probably already guessed what the to upper case method does . It changes the lower case letters in a word to upper case, and you'd be correct to show you how to use it, however, is a different story. So let's first start by creating a string variable and full of string variable. I'm gonna allow the user to input a wood so string I would equals option pain, input dialogue and in the brackets into a wood. Of course, I still needed import my job X wing packages, but there is a cheap shortcut by just clicking the last hope and at import off job X wing J option pain. However, I would recommend using this all the time. You may have to use other assets, so it might save more time and lines of code if you just import the entire swing package of assets and you do that by just using a star after the dot swing Now we're going to start using our method. So let's create a second string variable and then change it. Actually, let's save some lines of code AEA and make a system our front line and just print out the word dot to upper case and brackets. Seen as it isn't method. Now, when we run, the program will be asked to enter in a word, and if our code works correctly, it should change the words laters, which are lower case to upper case. So let's top in the wood. Hello. And as you can see in the are foot, everything is to the upper case. A method such as this is offered news to do things that the user isn't required to. For example, the user enters in their name but doesn't use capital letters for the first letters. This method will come and hand you in assuring that those laters are in their capitals. The to upper case method is then used on the first letters, and don't worry if they're already in caps. At least a man is the to upper case maids that worked to fix anything that's already in caps, and to prove it, I shall run the program again and write the word Hello again. But a few letters in a capitals now when I run the program. So as you can see, full caps and everything that was in its upper case has been left alone. In the next video, we will discuss the to lower case method. 18. The toLowerCase Method: Hello and welcome back to advance Java programming course. And in this video, we're going to be discussing the to lower case method. Now, in our last video, we discussed the to upper case baited and we learned how to use it properly. In this video, we're gonna in about the to lower case which, as you can give, is very similar. So we'll start by creating a string variable once again for the user to enter in a wood. Now that we have created our variable, we're going to create a sick and one way we're gonna add the two lower case method. So string result equals And just like the to upper case, miss it, we top in the variable name I would dot and now the methods name to lower case and clothes of a semi colon brackets at the end of the method. What this should then do is change any uppercase letters that the user enters into lower case. So let's not print out the result with a system our print line. Now that we have done that, let's run the program. We now have our input box. So let's stop in something using capital letters, so h e l l and then a lower case. Oh, so we can see what the method does to lower case letters. And when we run the program, we can see that all the capital letters are in the lower case. Now, before the video ends, we're gonna discuss how these two methods the to upper case and the two lower case effect characters and not letters or numbers but actual characters, as in the full stop, a question mark and so on. Well, this is avoided, tested out. We just run the program again. And this time in our in foot box, I'm gonna write a sentence with a few characters and a few numbers. So I'm going to write Hello, How are you? Question Mark and I'm gonna add a number afterwards. Let's say 25. Now we run the program, weaken seeing the characters, and the numbers are unaffected by the to lower case method. But the capital age for hello has been put into its lower case. The to upper case and the two lower case methods or what we call fixed methods, as in a specific top off daughter, is affected in this case text being letters and upper case and lower case so any other top of daughter goes into this fixed method remains unchanged, so fixed method only changes. A search in top of Datta so omitted that isn't fixed will affect all tops of doctor. We will touch upon this more in the rest of the section. When we encounter some fixed methods and methods that aren't fixed in the next video, we're going to learn about there is litter method. 19. The isLetter Method: hello and welcome to advance Java programming course. And in this video, we're going to be discussing that is letter method. Now, before we begin, I've got a first introduced variable known as the building variable. The 1,000,000,000 variable can contain three values only true, false and know if there is no value, this variable comes in handy when checking certain things. In this case, we're gonna be checking a character. But before we get to that, let's first start by creating a boolean variable. It's a simple is great in any other variable we first help in building B double o l E a n and then we give it a name. So let's just say test equals and then we could say true or false. So truth, there we go. We have now created a boolean variable and have given it a value. In other words, we have initialized and instead created a variable. Now we're gonna use this variable when testing our character. So before we begin chicken characters, we must first create variable to contain that now a character is one value. So we use a char variable so it is called char ch equals and Now we are going to ask the user to enter in value. So we use J option pain show input dialogue. And now, since it's a trial available, were to convert this string that the user or enter into a chart. So we add the doctor charge at method at the very end, so place zero in the brackets, so it will be the first letter that the user enters. We're gonna ask the user to Internet any top of character so we can say inter character number or later. Now the chart at Method will pick the very first letter number or character that the user rots in their string. And we're gonna use this building test Grabel. Now, instead of giving it a very true we're going to start by using Miss it. The method is later comes from the character close. So we topping character dot is later and then brackets, as you could see, it's really auto generated the nearest char, which is in fact ch so we'll leave it as is. What this will then do is take that character variable and check to see if it is a letter. The output off this chick will be either true or false. And if there is no very no. So if CH is in fact a litter, the Boolean test variable will have the value. True. But how we gonna taste that out? We use an if statement with the top. If test equals equals true and in between our records, we'll create a system our print line that will tell us whether the character is in fact, a letter or not. So it was a C H plus. And then, in our quotation marks is a letter I have now created an else in addition to the if statement. So that way it'll tell us if the variable is not a letter. And with that, let's start running our program. The very first thing that should appear is the input dialogue. It does appear that are supposed to enter in a character number or letter. So I'm gonna top a letter first. So let's say the letter G. And as you could see, if statement works correctly, G is a letter. Now I'm going to run the program again, and this time I'm gonna enter in a number five is not a letter, which is correct, and we're gonna also use a character. So let's use the dollars symbol and the dollar civil is not a letter as well. Now let's go a step further and try using a capital later. So Capital G and Capital G is still a letter. So our character that is lit, omitted has worked correctly and returning a 1,000,000,000 variable that tells us whether a char is either a letter or not. Boolean variables and the Isleta method would no doubt come in handy when checking variables in the next video we're going to be discussing that is digit method. 20. The isDigit Method: hello and welcome to advance Java programming course. And in this video we're going to be discussing the method is digit now. In the last video we discussed, the method is letter. Well, Is digit is very similar, so let's begin by re creating that program we did in the last video and adjusting the values. According me, we first grated arch are variable, gave it a name and then used a J option Pain doctor import dialogue open brackets into in a character number all later and they were used the dot char at May 3rd to get the first Valley that the user enters, we now create our Boolean variable called a taste equals. And again the is digit method comes from the character. Close. So we top in character Dr is Digit and then we top in the character's name Ch and close up a semi colon. This will return a Boolean value which will be a sand to the billing test variable we now create our if statement. If test equals equals true, you and then in the brackets will place a system our front line and with our Valena C H plus and inside the quotations is a digit or, if you prefer number, as you have probably really noticed, unlock the program we created in the previous video. I do not have an else, so let's create that now. It is not necessary to have an else, but I found that having a default is always good programming. We've now created our default, and so when you run the program were presented of the input box once again, it up in a character percentage symbol again. And as you can see, percentage is not a digit or number. Same should go for letters such as H H is not a digital number. And now, for the moment of truth, we talked in a number five five is a digit number. This is just another variable checking method is digit chicks. If a character is a number or not, just like there is little method checks. If a character is a letter or not, in the next video, we'll discuss that is what space method 21. The isWhiteSpace Method: Hello and welcome to your advance Java programming course. And in this video we're gonna be discussing that is what space method first, let's practice with the is what space method now lock. The previous methods we've used is later is digit is what's based chicks to see if a certain character is what space, what space being the character you create when you press the space bar, as so as upper T space and then another team, it senses that character in between the two teas. So let's test out this method. We create our child variable HRC age equals RJ Option pain dot show input dialogue and in the quotations in tow lot space. Since J. Option pain outputs a string, we need to convert to char using a chart at Method we use zero. So the first character is selected, enclosed in a semi Koran we now create are doing valuable. It's cool, temp equals and character, since that is what space method is a method of the character. Close docked is what space and it's already detected ch as a char soda selected it, and now we're going to skip the if statement and go straight to a print lance, so we can see if the Prince truell False. So his sprint Tim and from the program we're now presented of the input box. I'm gonna top in a letter first. As you could see, it prints false because tea is not what space and will be the same for numbers as well as other characters like the percentage symbol. But its taste out. What space? This place, this baseball and click OK, and it prints truth. So this is this is what's base method. So we have now gone through three methods from the character class. The character class is a set of programs that we can call upon whenever we want. A class is also our end goal for this corpse. By the end of this course, you'll be creating your own classes which will have their own programs in a way, your customers in your i. D. E by having sit programs that you can reuse whenever you luck. These three methods is Wat space is digit and is letter will become very important when we progress with scanners and other means of scanning lands of text numbers or characters thes miniature programs or no doubt come in handy when creating larger programs. In the next video, we'll discuss a new method known as the dot length method. 22. The Length Method: hello and welcome pure advanced Java programming course. In this video, we're going to be discussing that dot length method. Now. What the dot length method does is returning interview available. Howard gets this variable is the trick. The dot length method tells you the length off a string. So, for example, are top in this string. Variable. Let's call it Word equals allergists say hello close of semi colon. As you could see, the length of this string is far is five letters. Now we create an integer variable that's cool number top inward and then, of course, the dot length method and brackets and close of the same. You, Colonel. What this will do is scan the string in this case, Hello and return an integer in Teacher Bean the length of the word. So now let's print out number so we can see if it works correctly. And as you could see, it prints the number five so the dot length method works correctly. This can or should work with your J option pains. So, as you can see, we have, I'll show import dialog, keeping the use of the power. Now we don't print out the result. So when I run the program, it has an input box, which I cannot contain. What a vile lack. I can enter in a full sentence and all measure the characters. So let's try using something basics such as Hello again. Way Get Fasth Correct. Now let's try using two words. So hello, their eyes. You could see the number of letters in this one is 10 but the number of characters and this one is 11 now. This is the difference between what you might think the doctor length method does and what it really does. The dot length method measures the number of characters, as you can see here, it produces the number 11 which is the number of characters in the string that I had before . Let's try using a smaller won t space t. It should then return three. And as you can see it does. The doctor length method is perfect for measuring the length off string, meaning not the links off the letters used. But the length of characters in a string can discolor, plowed two numbers was gonna plateau white space. This can apply to characters and laters everything that the string contains will be counted . This method can be used in different ways. For example, you can great a program that only allows the user to maintain three characters, such as in Old Arcade Video Game were you only allowed to enter and three characters as your name and in the wild loop would be the wood variable that you used. And while that would is greater than three, so the loop will keep running until the user enters in a three character long strength, a perfect example of how the dot length method can be used to check string variables. There are no doubt more applications for this method, but is various simple, so I don't think you need to do too much practice on it. In the next video, we'll discuss the Dutch compared to method. 23. The compareTo Method: hello and welcome to your advanced Java programming course. And in this video we're going to be discussing the dot compared to method. Now, before we begin, I would like to introduce the number place system for laters and characters. The number place system or the ask e table is the number that the letters or characters are sound. For example, the litter A in the lower case is assigned the Valley off 97 B is then Hassan the value of 98 C 19 on and so on, and it goes with characters as well. For example, the colon symbol has 58 assented. The semi colon has 59 and so on. You can check the asking table online to see the exact value. Now The reason I'm telling you about the asking table is because that dark compared to method uses asking values to compare certain characters. For example, let's say I create the string variable string would one equals, and I'll give it the value off just the letter. A lower case and for our second variable are great. Would, too, and I'll give it the value of B. But the doctor compared to method does is it takes the values off these two, for example, A and B, and it'll get there. Ask you values and deduct them from each other, depending on which order you put them in. So, for example, it will convert a in its head to 97 then it will convert be to 98 then or deduct 97 from 98 or 98 from 97 all return a value in the interview form. So let's use the doctor compared to method. Now I'll create and interview variable to place the Valium so into numb equals. And now this is where we use the method. Now, depending on which order you place, your variables in it can return a different value. The 1st 1 replace is the original number, and the 2nd 1 will place into Elevated is the number that is deducted from it. So if our place word one the value of 97 1st then on our place there would to second the value it'll return will be negative one because 97 minus 98 his negative one. So let's chase that out now. Our top inward one as always have omitted. We top the variable name first, the duct and the meta's name compared to in the brackets. As you could see, it's already found another string variable, too. Compared to in the brackets. All have would, too. Now, that's great. A system, our print land so we can see the value and place the numb variable inside. Now, when I run the program, you will see it has returned. The number negative one, as we predicted, has not taken the two values 97 98 to dr them from each other and given us a negative one. Now I'm gonna show you what would happen if we replace them. So let's say would to is compared to word. One is then take word to use value and minus word ones Value giving you the number one which is correct because B is 98 8 97 98 minus 27 is one. Now what is the use for the doctor compared to method? Well, we use the dot compared to method to organize strings or characters in alphabetical order. This is the most common use for the doctor compared to method. So for example, Let's take these two lines away, and now we're gonna add an if statement. So your top in. If would one Dutch compared to you would. Two is less than zero. This will then mean that a shouldn't come before B. Then we print out. Would one and we print out Would, too, in alphabetical order. And now we're creating else we were top in the reverse. So would two and then would one. So if our program works correctly, it will compare the two word variables to each other and organize them alphabetically. So if I run the program, you'll notice a is printed before B. So let's say if I switch it to be and A you'll see is still written a before B because this does not fulfill the clothes and if statement so it will use the els, which is printing the second word variable before the first. Now, this method will also work for full words. For example, we don't have to have a single later we can have names, so let's give an example. Name off Robert and a sick and name off Phil. Now, as we know, P becomes before our so what this will in due is redid character by character and all. Print Phil before Robert. So let's run the program and we will see it is indeed doing exactly that. It reads the first latest and co pays them. Now it's gonna also work if the names all the same. So let's say our top in another name that begins with P. Now, if these two names were organized in alphabetical order, Peter would become before Phil because E becomes before h. The program is in talented enough to do a character by character comparison, so it will compare the peas realize they are zero move onto the next one, the next one being e and H compares these two characters to each other and that will return the valley. Now, when we run the program, you see that Peter is indeed printed before Phil. Now, before we in the video, I'm gonna show you what the number values now, were you on the program, you see that the value is negative three. Now, what you might have expected was negative one. The reason for this is because E has two more places before h. So then it is two numbers higher than E. So therefore, few minus H is number from E. You'll get two more or less then what you expected when you compared A and B the way to better show. This is if I have the letter C inward to and the letter a in would one. Now, when you run the program, we'll see it's negative, too. That's because the Valley for C is 99. That's the brilliance off the doctor Compared to method, it doesn't just look at whether it comes before after it looks at the difference. So therefore, we can organize anything from large strings to small characters passages practicing with the doctor compared to method before moving on to the next video experiment of the asking table by comparing characters themselves and other letters and also doing your own sort of alphabetical order program so that you can learn to organize characters and words in the next video, we'll discuss the project for this section of the course 24. Project 2 Discussion: hello and welcome to advance. Drove a programming course, and in this video we're going to be discussing the project for this section. For this project, you're going to be entering information of random users and organizing them alphabetically . There are three things that the user is going to enter first name, surname and their age. You were only ask for two entries. Each injury has to have an age above 18 years old. You're then take thes two entries and organism alphabetically by surname. For example, if you have a surname that begins of C and a second surname that begins of D. C. Should appear before D, but you're then do is rewrite the results to give the following the first later off the first name full stop a space and then they're sunning. And then afterwards, you'll have in their age underneath their name. So here's some example information, and here is what the result should be. Here are a few hints, or what methods you should use. Forgetting the initial off. The first name used the doctor char at method for organizing alphabetically used the dot compared to method and the correct if statements to organize them. You may create two separate string variables which will contain the two entries finished product. You will use a wild new when checking the age that the user enters. So that way it will keep asking until the user enters in a appropriate name and surname with an age that is above 18th. Finally, to ensure that the letter off the first name is in Capitals, you're gonna have to use the to upper case method for this project will always assume that the user enters in a surname that begins of an upper case. Later in the next video, I'll show you how to create the program. 25. Project 2 Answer: Hello and welcome to advance Java programming course. And in this video, I'm gonna be showing you, huh? Write the code for the project for section one. Now, before we begin programming, we first have to create our project. So it's click New project job application. And I'm gonna call this one sort, because that's what our program does. It sorts information. Now that we have created our project, we have to import the following assets import Java ex dot swing dot star. The reason we import these assets is because we're gonna be asking the user to enter in certain information. So we need the right assets to create the right input boxes so they use a conducive. Now we begin coding. The first thing we're art are string variables. So I'm gonna show you what string variables I used in my program First Great string. Now we could create a long list of names, but I'm gonna include them all in one land and give them values in case the user does not enter in something. So it has to use the blank values that already stored. So string name equals and let's give a blank and then we'll have a last name for the last name that he used a intervene. Also give it the value of blank First for the result that comes first. So if our users surname comes first on the list, it will be put in the first fable and as such will create a 2nd 1 as well. Second and leave it as blank. And finally a temporary Well, there's Tim Variables. The variable. We will compare the last name too. So we have to give it a particularly high value in case they use his name begins of Z. We have to then call it zzz. I'll show you how this works later on. We now creates an inter variable age equals zero. Now you may be asking why do we have to create an age variable if we're only going to be comparing strings? Technically, we can just store age into a string variable. And it was still work, however, prefer to put the age into an invariable in case we have to later use it in sorting. So we now create our full statement which will repeat twice so we can intend to users values. So full hint uh, equals zero I less than two. Hi plus Plus, we can also use a while loop. But then we have to create account variable. This one has a built in count variable, as you know. So we will use this. We now creates a while loop for the user to anti in the age. It'll constantly repeat until the user has entered in an age that is 18 or buff. So while age is less than 18 I have shown you this particular close in our previous video where we discuss the project. Now we're gonna have the user into in the valleys. So we're started name and then we'll start using our J option pain, not show input, dialogue. And as I mentioned in the discussion, we don't know whether the use or into in capital letters and the result should be in all caps. So we use the doctor too upper case to solve this problem as well as save us code later on and inside our brackets for the show, import dialog was say, inter your first name and stop the when I create a second variable last, which will store the last name. Now I'm just gonna copy this line of code since it is essentially the same code and change first to last, the user must not contain the last. We now create 1/3 people the age variable. Now age is an integer, so we have to pass it before we use our jail from pain. So introgen dot pass int and then Jay option pain that show input Diet Coke Enter in you'll h enclosed BC me colonel, and that should do the wild leap. Next we create that if statements which will be using our compared to mitt, stop writing if temp. This is the variable that I mentioned earlier dot compared to and we'll use the variable lost since we sought in my last name is greater than zero. That's our first. If statement done as you can see it will compare the temporary upon the last variable. And as you could tell from the capital's ease that when you compare temp and the surname it will be greater than zero, meaning whatever happens in this if statement, it should place the result very in the first variable. So I'll show you that. No. First we gotta replace the temporary Able for the next user, so temp equals lost. Now this one then do has changed the temps very from Triple Z to the surname that was you perform well later, when the user enters in is second values. It'll compared to this last surname certainly would be able to sort it alphabetically is in a compared to method. The next great second equals first. At the moment, this does nothing, but let's suppose he uses first values. Surname begins of a B, and they use is sick and value begins oven A. That means that a must come perform be therefore, to run this part of the if statement again. So what will happen? Teoh First valleys well, there will be deleted or replaced, so we have to make sure they're not deleted and placed into the second variable where it will be printed in the result. So second equals First, on the first run of the four loop, you'll notice that nothing will be stored in second. It'll be blank because we have yet to give first of value. Next, we now have to give our first variable its value off name Char at zero. This will stall the first letter off the first name, which is what our results should look like. Next we add a full stop in the space in between and then we add the last name. Now, finally, to complete the first result after at the age. And to do that, we had a press time open our quotations again, backslash in. So it'll start in Milan and age, and that is it. Our first values will be stored black, sir, Next to creates. And else this is in case the user enters in a last name that comes after the last name they really entered, which means it will be put into this sick and Babel. And we only have to create one more land, which is second equals and we can copy this year, since this is what we're gonna be putting into the variable. And just like that, we have completed our if statements Number four, we closes the four lip. We have to make sure that age is returned to zero. The reason we do this is because our wallet would check the age variable. And if it's still higher than 18 well, then it won't run. And you only get one value. This may cause future era, and now we've completed the core part of the program. We only have to print the result. So we create our system. Our front line, let's say first plus backslash into starting you on as a second, and that should print our results perfectly. Now I'm gonna use two runs to prove whether the program is working among to run the program . The first users information I'm gonna enter will be a last name that begins with B. So our top in Steve and I say Bravo and it's given age. That's the lure 18 so we can check with our while. Loops runs properly, so we top in 12. It runs instantaneously. But how do we know that our information has been entered in properly? Well, we just have to write the information again. It won't ask us for more information. If it didn't run. Probably so let's just see if it works. So, Steve for all of them. And let's give it a name. Age of 18. So 90 and it has all stars for information which means are wildly worked correctly, and now it was sick and information that I'm gonna contain There's gonna be a last name that begins with a So stop in Steve Again, Alfa and the Age Let's make it again less than 18 12 and it runs again. Our wire loop is still performing correctly. So Steve Alfa and let's say 56 and Alfa has been written before, Brother. There's the age, and it is the correct format. Everything is in Capitals. The first letter off the first name. It is all working correctly. Now let's run the program again, and I'm going to start with L for and then move on to brother so it's top in a different name. So Richard Eltham City full and now sick and information. Steve Bravo 67. And as you can see, Alfa is still printed before bro over, and our program is working correctly, and that concludes our project for Section one. Compare your program to Mahon and see if there's any errors. All programs can be improved or code removed, so if you notice something in my code that is unnecessary, feel free to remove it and create a more efficient program. If you have a working program that has the same or less lines of code, then congratulations. You have completed the first project in the course. In the next video, I'll be concluding what we have learned in Section one. 26. Conclusion to Section 1: and that concludes Section one of your advance Java programming course. In this section, you learn several methods that will no doubt help you in building programs. Not only did he learn about thes methods, but also learn how to use them together to create useful programs. These are not the last methods you will learn in the course, but these are the essential methods for continuing it. 27. Introduction to Section 2: Hello and welcome to six and two of your Advanced Java programming course. In this section, we're going to learn about essential lands of curd called sub String and Index. All you need to properly understand these two methods sub string and index off. To fully understand the concept of object orientated programming, Sub string and dot index off our special methods that we use to process strings. Thes two methods are very useful and processing daughter that the user enters the sub string and dot index off methods are not exactly difficult to learn, but they do require a lot of practice on your part. You need to understand strings Charles and, of course, another place system that are mentioned in the last section as this information is extremely important when learning how to use the sub string. An index of methods if you keep this in mind in sub string and index off will be no challenge for you, and these air central methods will no doubt help you in the future. In the next video, I'll give you an introduction to the sub string made 28. Substring Introduction: hello and welcome to advance Java programming course. And in this video, I'm gonna be introducing you to this sub string method. The sub string method is used to separate a string and return a specific section off that string. For example, we could have the simple sentence such as strings are lines of text and we could then use the sub string method to cut that string. We use numbers to decide where the string is cut. For example, we have this line of code yet assumed that we have already created a variable containing a string called sentence and placed in this line of code. So string temp equals sentence dot sub string and in the number five in brackets close of a semi colon substrate method will then cut the string sentence at the number five, meaning at the fifth place in alarm of text. And this is where our number place system comes into play. If we wanted to cut it at the very start, it would be zero instead, if we wanted to cut the string after the first character, we would use the number one and then number two after the 2nd 1 But we have five in this bracket. So after the fifth, later the string will be cut. So let's take that sentence. Strings are lines of text and find out. Where do we cut? If we follow the number Place system 01234 and five. You'll notice that the land is right before G in the strings. So then the centers will be cut and the following will be displayed G S R lines of text. You can even go one step further and not only decide where the string starts, but we it ends as well. For example, we have this lot of code string tip equal sentenced on sub string five comma seven Closed the brackets semi colon. But this will then do is start off the string at the fifth place, as we saw previously, and then end it after the seventh place. So if we have a look at our sentences once more, we will see it started. Five. So that's G and then ends at seven, which is rapper for space after strings. So the following will be displayed G s. This is how to simply use the substance method. But there are special ways in which you can have the computer choose the places in the sub string to divide. But that will come later in the next video. I'll show you how to use the sub string with a few more examples in the actual net beans, Adi. 29. Substring Practice: Hello and welcome to your advance Java programming course. And in this video, we're gonna practice using the sub string method. Now, before we begin, we have to first create a variable string that we can then use to cut with the substrate method. So string weird. Actually, it be very record sentence since it is gonna be a sentence. So it's called ST equals. This is a random sentence. Well, stop close if it's semi colons and now it's great. Our second string variable, which we're going to separate the string sent into so strength would equals. And now let's use the sub string method. So let's say I want to remove everything before random so than our top in ST dot sub string and closer semi colons. As for the number that goes in the brackets, I can just simply count it. So it's 123456789 10. So 10 should be the right number, and then we print it, and it is a simple is that so It's run the program and we have a random sentence. Notice that the space before random is not there. If you have a space that means you're number system is a little off or if you missing and are again, it is not correct. I want to have worked with the number place system long enough. The substrate method is very easy to use, especially when deciding where to cut the string. Now let's go another step further and we're going to separate a specific would not including the space and I'll say random would be the ideal would. It's a very simple adjustment. We have 10 comma and as full a number a C 10 11 12 13 14 15 16 so 16 will be the rock number to use. It's all the imprint of random, not including the space after as it cuts before the space. So we run the program again, and now we have random and as you can see, there is no space before or after. This also works with user generated sentences, so create a quick J option pain input dialogue into enter a word sentence you, another user is the power to enter in the sentence. So our top in this is another random sentence and in today, so it took other from another in another random sentence. Now I'm gonna show you a common era that you may experience when working of sub string. So I'm gonna run this program again. But I'm just gonna top in one would hello and click. OK, you notice it will give you this Aero via string index out of range 16. The 16 is specific to this lot of good. But what I'm trying to point out here is that the sentence that we entered in is far too short for the sub string code over here for does not have 1/10 or 16th character. If it was much shorter and we had to and three and re topped in that simple would hello, it is now within range. So be careful and using sub string as it may result in errors if you do not use the correct numbers. However, as you can see, the substrate method is useful for dividing strings into simple words or characters. In the next video, I'll be telling you about the two myth. It's index off and lost index off as they will be the special methods that were canned in hand with the sub string method 30. indexOf Introduction: hello and welcome to advance Java programming course. And in this video we're going to be discussing the index off and lost index off methods. I'll begin with the Index of Method. This method is used to determine the place of a char or string in another string. This method will return an integer depending on where the char all string is situated in the large string. For example, we will have this line of code here into temp equals, sentence dot index off open brackets. And then you'll have single quotation monks because it's a char, and inside the little are close brackets semicolon. What this will then do is scan through the symptoms variable, look for the first R and then return an integer using a number place system that Smith. It isn't set only to Charles and also works with string variables. So if you're looking for a specific line of characters in a string, it'll work just as well. If it was a single chart variable, the code will be written as follows into temp equal, sentenced on index off and then double quotation marks inside the brackets because it is a string and then a full word such as random. So if we take the sentence, this is a random sentence. It will locate the first instance of random, and then it will return the end that positions it in that string. The index off method scans strings from left to rot, but suppose you want to find a specific character or word that is situated near the end of a sentence. In other words, it's the last appearance of that char or strength. Well, that's where the last index off method comes in. It works the exact same way as the index off method, but it reads the string from right to left. So the code will be written as follows into Tim Equals sentenced or lost index off single quotation marks and whatever charge you intend to look for a Z, you've probably already worked out. You can use these numbers in a sub string method. You can then insert thes interview variables into the substrate method as follows. So let's assume we've created an inter very born of his Sanders and Index off method. Well, then, use that invariable. Let's say, numb in this line of code here, string tempt equals sentence dot sub string in the brackets. Numb close to me, Colonel. But if you want to save yourself a few lines of code, you can just use string temp equals string dot sub string, and then within those brackets you have sentenced stock index off. And what if it character you tend to use In the next video, we will practice using the index off and lost index off methods with the sub string method . 31. indexOf Practice: hello and welcome back to advance. Drove a programming course. And in this video, we're gonna be practicing with the lost and ex elfin Indyk South methods with the sub string method. So let's start by creating a simple string such as Strange ST for sentence, he calls. And inside we'll have a random sentence close if you see me, Colonel and now we're gonna taste out the index off method. So we have to create an invariable. Since the index off method returns and Inter Variable it's called in NUM equals top and sent dot index off. And let's test out of character for his 1st 1 so that a single quotation marks and let's say our we didn't create the output lan that'll print to the number that the index off returns. So we have our over here. So if we follow our number place system, that's 12 so that should be, too. And as we could see our index off mate, that has worked correctly, and we have to as a result. Now let's taste it again. But using a full word such as random now, if this works correctly, it's just still print out the number two, and it does now. Let's taste out the lost meetings off now. As I said in the last video, the last mimics off works in the opposite direction to the index of method index off works from left to rot. But last index off works all right to left, which is useful for finding the last word or the last space in a sentence if you intend to remove the last part of the sentence. So we're gonna change the value of the brackets to a single quotation mark and let's say the last space and then we top in lost index off instead of index off. Now, if we follow this line right here 12345678 So it should be eight. If it's working with the last space, is that normal index off will work with one. So let's print out the result. It prints on eight. So does indeed work correctly, and just so you can see how the normally takes off would print the result, it's run the program again, but this time it will print one. Since it works from left to right. This is the first space it comes across on the last index off. This is the first space it comes across. Now, suppose we would like to separate the sentence using a substrate within this sub string, we're going to use the index off methods. So we're gonna take this example sentence and we're going to remove wood random. And the way we do that is simple. That's removed the output land first. And now let's create the substrate. So we're gonna take a string variable called Word. And now we're gonna use sub string with percent variable dot sub string, and we intend to remove the wood random from the sentence. So we'll have to do then is top in the index off. That fits the parameters. So that would be in dicks off. And then, Brandon, we didn't create a simple are Portland. It happened. Print would now, as you may be, very guest. This is not going to do what we wanted to do. It will cut off the sentence at random, but it will still have following after the wood random in this case, space sentence. So we're gonna have to do is add the second value to the sub string But how do we work out the value correctly? Supposing that random is anywhere else in the sentence doing Is the Lost Index off? Well, that would work as well as you know, because it will print out with random sentence starts. So then the result will be If we use the exact same word and the last tunics off, it'll just be nothing. Nothing will be printed. There'll be no value since it stops and ends at the same point. So what we will then have to do is taken account for the random itself. So we take in how many letters would be. So that's 123456 That's six letters. So it's simple. We just copy this line of code topping plus six. And since meth also works within the brackets, this should print out exactly what we want. And it doesn't mean we have wood random, and as you can see, there's no space before after. So now that we've created a flawless line of curd for searching for, the one would random in a sentence, we can now have the user input the symptoms. So I suppose we have another string street sent equals and a J option pain input dialogue and enter a sentence containing the word random because of a semi colonel. Now, since we're no longer using this line of code, we can remove it it as well. And now we run the program. Wherever we talk random in a sentence, it should work correctly. So this is another and random sentence that I'm rotting. And as you can see, random is removed out. Space is perfectly done. You must take note that it is especially important that you create lands of code that do not rely on you to constantly change. To suit the user, you have to create lines of code that suit every user. In other words, it has to be universal, depending on what the user enters, as long as it contains what we are looking for. The code should work. We do not have to always adjust it. For example, I could change the slant of Kurt to specific numbers, but the user may not enter in the wood random in those specific areas. This is a more advanced way of looking at the sub string and index of methods. The lost index off method does come in handy. That index off should be the main method that you'll be using. So don't worry too much about the last night Knicks of Method. I recommend practicing with these methods together because they are definitely come in handy when it comes to object orientated programming, which is the final section of our course. Using these three messages, you might get a better idea of the number place system and working with Masons hand in hand , which is, no doubt an essential skill in programming. In the next video, we'll discuss the project for this section. 32. Project 3 Discussion: Hello and welcome to Advanced Java programming course. And this video. I'm going to explain the project for Section two. In this section, we covered three methods. Index off lost index off and sub string. You're gonna make use of all three of these methods in a very simple program in this program, you're gonna ask the user to enter in the first name, middle name and last name all in one line. And then using these three methods, you're going to separate these three different names into different variables and display them as follows. Once you've displayed all three names as follows, you're gonna have to take all three of these names and put them together and display them as follows here, the first name, the initial for the middle name, and then they last night. The second part of this project will require you to use a method that he learned in the last section. Since we learned only a few methods in this section, the project for the section is basic. It shouldn't require so many lines of code, and you should have no difficulty creating this program. If you do have difficulty with the project, then our recommend going through the videos again in practicing with methods. In the next video, I'm going to show you my answer. 26 and two's project. 33. Project 3 Answer: Hello and welcome to your advance Java programming course. And in this video, I'm going to give you my answer. Just Section two's project. Before we start programming, we have to first create the project itself. So right Click New Project Java application and let's call this one sub string practice. And now we begin Koerting. First thing we're going to do is great. Very well that the users can input their names into so strength, and its goal of names equals J option, not show input dialogue. And as you can see here, there's an era because we do need to import the Java extreme packages. But for this project, it's not necessary to import all of them. So you can just click on the lab here and at import to Java X wing J option pain. And now we top in the brackets in tow. First, a little and last name with a space in between each name, and now we create three variables that the names are going to be sorted into, and this is gonna be using the three methods we learned in this course sub string index off and lost index off. So that's great the 1st 1 string first for first name equals names. Don't sub string records close of a semi colon and inside the brackets, we're going to start at the very beginning because that's where the first name is. So we're talking zero and we talking names index off and space is a character we're going to use. This will insult the first name into the first name. Variable middle name is a little more complex string middle equals names, sub string. And now we got to separate the middle name from the names variable to do so, we have to fund the first space in the names variable. So that's another index off. So that'll be names index off watch space comma because it doesn't. In May and next we top in names dot last index off space and that should probably separate the names. However, there is one more thing we need to do occurred that you see here will sort not earlier than middle name into the middle names string, but also the space before it. So what we need to do is add one, but this will then do is take up the sub string from the space before the middle name to the first letter off the middle name. This should properly remove the middle name from the names variable and place it in the middle string variable. And now, for the last name String lost equals names dot sub string names don't lost index wide space . And we're gonna also add a plus one because there'll be a similar issue for the last name and we don't need to add a second number value because the last name should be at the end of the names variable so we can leave it here with just one. And now for the output or great assist of our front line first Kerlon space and we are gonna be counting spaces with apprentice plus first plus and now back slash in to start a new life Middle Kerlon space plus middle. And the same goes for the last name Rust after the backs less in Colin Space last last and that should do it for the first part of this project. Now that we have run the program, we have to enter the name. So I'm going to use the name from the discussion in the previous video Joe Henry. Bloods like okay. And you can see all the names are organized into the respective line. And there's only one space between the first letters and their respective colonel. And now we move on to the second part of the project, which is to print out the full name. But earlier, the initial off the middle name and again, we only need one output statement. I'm gonna separated here from the main code so you could see it. But better said System I print plan First plus space. Fleiss middle dot char at zero plus full stop space last lost. And that should do it when I run the program. Joe Henry the logs take a king and, as you could see the first are put is still correct. And second output has the full name with no extra spaces in between names. And this is my answer to Section two's project. If you find that your program has more lines of code than mine, I suggest taken into the same tactics that have used in this one to simplify my code if you have the same amount of lands or less, which is possible. Congratulations. You have completed the second project in your Vance Java programming course. In the next video, I'll conclude Section two to the course. 34. Conclusion to Section 2: and that concludes Section two to your advance Java programming course. In this section, you learned three important methods. Index off last index off and sub string. Thes methods are very important as they've talked to you. A very simple form off scanning scanning is a process that you're gonna learn about in the future sections. But these myths it's helped introduce the idea of scanning, making future methods in scanning seem a bit easier than they would have. Bean, if you have just started with him, congratulations and coming this fall in the course, and I'll see you in the next section. 35. Introduction to Section 3: Hello and welcome to section three of your advanced Java programming course in this section . We're going to learn about the scanner clause and the print rata object. We are going to use the scanner class to scan text files that already made containing all the daughter we need and the print Roger object we're going to use to rot two ticks files. The scanner class is extremely useful, and you're gonna find that is one of the most important classes that you're gonna learn about an object orientated programming scanner. Kloss is a separate program that contains various methods that we use to scan text files. You will learn these methods as I teach you about the scan across the scan. Accost also contains other methods and objects that you can use to process daughter off other strings, not just text files. As we get closer to object orientated programming, these lessons become more complex and difficult to comprehend. However, if you take your time and practice these lessons, object orientated programming should prove no hassle. In the next video, I'll introduce you to the scanner 36. Scanner Introduction: hello and welcome to advance Java programming course. And in this video, I'm going introduce you to the scanner. First, you need to understand the hierarchy behind the scanner. We have the scanner class, and then we have the skin object. The scanner object belongs to the scanner close, and the scan object is what we're going to learn. With the scanner object comes several methods. Thes methods of the scanner object can be used to scan for different variables. For example, there are methods in the scanner class that can help you scan a string to find the integer a double at another string and separate them perfectly as if we were using our sub string method. While doing this. It also converts from string to whatever variable you looking for. For example, if you wanted to use the scanners method called Next int, it would fund the next integer inside a string and then turn that into an integer and place it in the interview variable. This is very useful for processing text in search of daughter were first gonna learn how to create a scanner. There are several parts to great in a scanner to create a scanner. You must first input the required packages. And once you have done that, you top the following scanner and this is the variable object. So now you have to give it a name. So scanner and the usual one is SC SC short for scanning and land short for what it is scanning a lot of text. So scanner SC lan equals new scanner and then open up brackets inside these brackets, you're gonna place a string variable which you're gonna be scanning, and then obviously you close with first semi colon, and that's what we have to do to create a scan of once you have not created a scanner and assigned it a variable. You can use whatever method you see fit to process the strength the final part through a scanner. Once you have finished scanning whatever daughter you needed, close the scanner and to close the scanner, you top in the variable name a C lan in this case, doctor close brackets and semi colon. It's a good habit to always close your scanners. Once you have finished using the way the scanner separates different variables from a string is by using a limiter. This is what separates the different variables. So in your string you could have several variables, but what separates them from each other? That would be what space. This is the default de limiter that the scanner uses. But you can change the deal emitter as you see fit as well. And you're learn about that later in the next video, we'll create a scanner and practice using it. 37. Scanner Practice: hello and welcome to advance Java programming course. And in this video, we're gonna practice using the scanner. Before we begin, we have to first import the packages containing the utilities that the scanner will use. And to do that, you go to your package at the very top click into afterwards and import Java got you till dot star and cynical or this will do is import everything in the utilities package, allowing you to use the scanner. Next, we start cutting. First, we're going to create a string for our scanner to scan. So let's create an example one that will be able to use all of the methods. So string and let's call it alarm equals. And now we have to include different variables that the methods will be asan, too. So let's create a string off and the limiter is a space. So let's put a space between each of these. Next we have an integer has put 45 no space, and we needed double said Let's try 5.2 another space and now we need a billing. So let's put truth, and that should do it for the string. So we closed his cynical. Now we create the scanner first Stop in scanner has called a C. Lahm says it's gonna be scaring the Larne variable equals new scanner. Open up brackets top in the variable name close of a semi colon. Now we get to a new lawn and we started signing the valleys in the land variable to their own separate variables. So let's great string variable would equals. And now this is where a scanned image that comes in We take our S Ilan and we use the dot next method dot Next funds the next string in this lan string. Next brackets close of semi Goan. You do not need to put anything in the brackets in this case because we've already done that of a year Now we create a interview variable to put the in valiant in number equals a salon dot Next brackets closes Semeka. Now we're going to do it for double and the billing as well. So double number two equals sc lon don't next double closer. Cynical on Berlin Taste equals is seeing alone dot Next feeling close of a cynical And now , as I mentioned in the previous video, we have to close our scanner and out we have finished using our methods. So it's seen on dot clothes and just so you can see the skin is working properly, we top a after put line that include all the variables, so word. And let's create a new lawn between each variable technician, plus number back in plus number two plus backslash in plus test. And if our scanners were correctly, it should print everything out perfectly. So let's run the program. And as you can see, everything has been sorted into the respective variable. There no spaces before, after as a scanner has learned to exclude these. So we have our string interject double and our 1,000,000,000 variable, so this can save us a lot of code when it comes to scanning daughter. So now let's create a jail champaign dialogue that the user can input their name and age and then use the scanner to get those valleys. So let's remove following over here, we'll still use thes two lands, remove the output and now let's create a gel option. Pain dia Lock inter in name and age. Let's make that the full name so I can show you how the next works, we now go to our methods. Now let's create a variable for the first name. So string first equals a salon dot next, and this will fund next string. And now we go to our sick and name String. Second equals SC Not next. This is the sequencing off the next in the salon. It will go past the first string as it's really being found using the next method of a year , and I go to the next string, which is this method of here. So this will be able to find the last name that the user tops in themselves and are obviously an integer age for the age a salon dot Next, and it's creating output. So first and now let's run the program. It's gonna ask me to enter in a full name. So Joe Blog's 30. And as you can see, the secret scene has worked correctly. It doesn't have Joe twice or blocks to us, and as each string and as the age printed out as well, so output is correct. This is how to use a scanner to scan a single line. In the next video, I'm gonna show you how to change the delimit er for scanner 38. Delimiters and Basic Error: Hello and welcome to your advance job, a programming course, And in this video, I'm going to show you how to change the D limiter to your scanner. As we've stated in previous years, the scanner has a default limiter off what space is hard separates different strings in tages chars or the more generalized him tokens. The watt space separates each token into its own respective field. As you can see a virgin, a simple skin of program which, when you run, displays the wood number and 45 as they've beans a sand to they string an integer variables . But now what happens if our replace the watt space with another character such as hashtag? When I run, the program you notice is an era. This is because the first part of the scanner rings true with string. Word equals SC Land Up next, it is able to fund the next string be the only one runner, which is number hashtag 45. But it can't fund an insurgent because there's no delimited to separate and a ginger from the other token, As you can see in the era, it says no such element because the is no integer for to take that that can be easily solved by changing the deal emitter to change the dilemma. To go to your skin a lot top induct use and then double quotation marks. Now you could even get the user to replace the dilemma tore for String that for now let's just change to hashtag and rerun the program. And it works just as it did before. The same result. That's because it no longer uses the what space as the D limiter it uses the hashtag you may be thinking, Why do we need to use? They used a limiter method. While not your daughter's gonna have lot space to separate the tokens, you might need to change it from Tom to town. Some daughter will have different the limiters throughout on your program has to react accordingly, changing it a limiter where necessary. In this course, we will not be dealing of such complex daughter. But there is daughter out there that does require you to change the deal emitter from town to town. So your program needs to react accordingly. And now I'm gonna show you how to deal with that era we encountered earlier, where it couldn't find it into jump because there was none. You might encounter this era again. If your scanner keeps looking for a string or into Joe other variable, that isn't thing. So what we need to do is create a way so that the scanner will stop when there's nothing left to scan for. And the way we do that is procreation a special while loop with a specific close to create this lip, we have to. Once we've created our scanner top in a while, open brackets is see lon DOT has next, and we use this special method as it returns a 1,000,000,000 value when there's nothing left to return in the SC land scanner. So now we're gonna drag our string in year. Let's remove the integer value for now, so that will be removed. So with our system of print land, we'll leave that as well. The loop will keep running so we can't have the scanner closing. So now we have string would equals a salon. Next, we're gonna remove this as well, and we're gonna replace it with an inter counter. So int count equals zero for now. And in Saudi loop count plus plus. And finally we need to use a next method. So let's create a string one string Tim equals s ilan dot Next rackets closes sim card on what the sleep will do is count the number of words or strings that appear in the S Ilan scanner. So let's great a example dot of peace for to use. So would hash tag taste hashtag would hashtag taste again? So now we have a total off forwards inside off the land available, so our account should in return four before it ends. So let's create the output system on burnt land and print out of the country. Now let's run the program to see if it successfully counts the number of words inside the land string. And as you can see, it does returns the number four and it closes the loop, avoiding any errors that may occur when it's scanning for a string that is no longer being . This is a simple solution to scanning through a string without the country and era, and that is how you change the scanners, delimit er and avoid a basic era. In the next video, I'm gonna show you how to use the scanner to scan a text file 39. File Reading Introduction: Hello and welcome to your advance Java programming course and this video. I'm going to show you how to use a scanner to read a text file. This form of scanner, otherwise known as a file scanner, works hand in hand with the land scanner that we've worked with before. To create a file scanner you need to write the following code scanner A C Far SC files the name we normally used for his file Radiant Scanner equals new scanner open brackets, new file open records and inside double quotations and routine in those quotations The name of your text file Doctor txt, close brackets, closed records semi colon Fear in mind that the ticks fall has to be positioned in your project. Otherwise this curd will not be able to read it. The reason it won't be able to read it is because it can't locate the file. It cannot search your whole computer for one single file. It will be able to find it in its Project folder. To get lands from the file, we use two methods. One is similar to the one that we used for our a C. Lance Genna Wild of the Clause SC file that has next, as you can see here and in that while it will have string variable equals a C file dot Next , learn. The next line method takes that loan from the text power and places it in that variable. You could then use your SC land scanner to scan that variable and get whatever daughter you intend to find. The limiters also work with the scanner so you can have at the very end of creating off S e files dot used a limiter and whatever character you intend to use as you delimited. However, it is easier just to change the deal emitter for your scan, Alon instead of Scanner Farm and finally just like the SC land scanner, you're gonna need to close a C final. So after you finish scanning a text file, be sure to top in the following SC file. Doctor Close. I will provide you with the text file containing raw daughter for us to process in the next video. I'll show you how to place this text file in the right project folder. So that way to be able to be rid by SC file scanner 40. File Reading Prep: hello and welcome to Advanced Java programming course. And in this video, I'm going to show you how to properly sit up the old program. So that way it could search for file in your projects folder First, let's create a program that we're gonna be using the file scanner in So need Project Java application and its court file, scanner and finish. Now that we have created our program, we have to import the various packages that will need to run the program. We have to import the utilities package for the scanner Java, don't you tell? Not stop. And for the file scanner, we need to import other packages as well. So that would be in Fort Java dot io dot star and those packages that include everything we need to read a text file. Next, we have to move the text file to the project's older. So if you've downloaded the rod text foul Raj, click on the file and click copy. Once you have done that, go to your computer. Go to your documents. It means projects and found folder that has the name of your project. So here's the file scammer, and once you have entered that folder. All you have to do is pace that text file. And just like that, you know, have a program that has everything it needs to scan a text file. In the next video, we'll practice using the file scanner. 41. File Reading Practice: hello and welcome back to Advanced Java programming course. And in this video, we're going to scan the text file names and process the doctor. The first thing you should be a whale is that there's an error that occurs when you do not have the text file. The program does notice this and requires you to create the close to prevent this era. For now, I'm gonna show you the basic method to avoid this era, but you'll learn how to handle this era more professionally in a later video. First we was create the foul scanner so we topping Scana a C file equals new scanner new file and the file's name is names Doc T. Eckstine enclose of a semi colon, and this is way it notifies you of the era to fix error. Just click on the lower bowl, and then it's easier add throws clause. This is the claws are mentioned earlier, a small line of code over here that prevents the era. As I said before, we will handle this era more professionally by giving the user message that tells them that the ticks fall cannot be found. Now we've got a process. The daughter in the text file. First, we was create a variable lan for the land scanner to skin. So string lan equals and give it a value off. Nothing for number. Before I close Islam, I'm going to create two more variables that we're gonna use to put the doctor in. As you may have seen in the text file, they are three tokens separated by hashtag, so we will have to change the deal emitter accordingly. These three tokens are name, last name and an age. So let's create variables for those three Turk ins. First for the first name. Give it a value of nothing sickened for a sick and name and also a video. Nothing. And finally, an int age with a value off zero and close it a semi colon. Now we create the wild lip that we're going to use to scan through the text farm. This is the wild I've shown you before. While SC file dot has next, this loop will continue to run until there's nothing left in the text file to skin. And now we have to create the scanner that will scan the land first. Let's give the land of value. Lan equals K C. Foul Dutch. Next. If our text file is in the right projects folder. Lana now have beena sand alarm from the text file a name hashtag the last name hashtag and the H snow. We have to use the scanner to process that daughter scanner. See, Lan equals new scanner in brackets lon. And now we have to change the deal emitter from the default watt space to hashtag close of a semi Kotal. Now let's a son are three variables their values Fist equals a salon dot Next pleasure to see me come on. Second equals is salon dot Next, was it a semicolon? And finally age equals a salon dot Next int since it is an integer another string and now we have assigned are three variables. They values what we have to do. Since we've completed our methods, we have to now close the lawn scanner and lastly, we need an output. So let's create our Alfred land first and I Let's separate them using tear. It looks more needs in the final output max slash t plus age and that finishes Ah, while loop It has everything it needs to scan through the text phone so outside the wall, if we need to close the file scanner, hissy file dot clothes brackets, semi colon, and this should complete our program to scan through the text far, process the daughter into information and display it neatly. Sell it to run the program to see the result. And as you can see, our program has worked perfectly. However, William Stephenson seems to have a much longer name than the others, so the doctor does change a bit. When it comes to him, however, you can see the rest of the daughters displayed neatly, and this concludes our practice. Using the file scanner, I do recommend creating your own experimental text files that you can use to scan because the practice always helps in the end. In the next video, I'll show you how to rot to a text file using the print rata 42. PrintWriter Introduction: Hello and welcome to your advantage. Drop a programming course and in this video we are gonna be discussing the print. Arata. The print Terata is a useful mini program in structure. The print Terata is similar to the scanner. The code is as follows Print writer out file That is the name that we usually give our Prince Rogers output to. A file equals new print Trotta brackets, new far Arata all brackets and then in double quotations the name of the text file you're writing to cause of semi colon. What the print Terata does is allow you, the programmer, all the user to write to your text file through the i. D. This can be done using a familiar method that we used to output our daughter. The printer Lon is simply tough in the following the name of the print writer in this case out file Dr Pentland and in brackets, what you want to print it could be either variable or just a lot of text. And just like the scanner, you need to close the print Terata once you have finished using it. So it's done in the exact same way out file dot close brackets. Semicolon. The print Trotta is very similar to the file scanner, so you do need to have a throws. Io exception clause, just in case of text file is nothing. However, there is a second part to the print rotter when writing to text file. If there isn't a specific line of code in the print Terata, then it overrides whatever's written and then a text file and starts a new when we created the print Roger Out file. What we did was great. A non true print writer. This means that whatever's written to the text file will be over written Every time you run this print trotter, however, this could be changed by just adding one word. Go to the brackets of the file name and ed after the double quotations comma. True. What this does is make it a true file writer, meaning that it will not override whatever's in the text file and instead continue with a text file lift off. I provide you with a text file that we can use to practice with when we working with the print Terata in the next video, we'll practice using the print Terata 43. PrintWriter Practice: Hello and welcome to your advance Java programming course. And in this video, we're gonna practice using the print Terata. Now, before we begin, you must do the following Create your print rot of program black. So import thes three packages and finally copy and paste the text file are provided you with printing dot txt into the project folder lack. So once you have done all of that, we can now begin programming. First, we want to take care off the era that appears with the print trata. And to do that, you have to public static void main you see at the top after the bracket, before the curly brackets open your top in the following throws. I o exception. Once you have done that, we begin the main program. Once you have done that to begin programming, the main program top in the following print out file equals new print. Roger, open up your brackets. New foul Raja Frontin doc t 16 and then close off a semi girl. Once you have written out the print line, you must now close outfall. And now let's run the program. It should say build successful, But the real output is gonna be in the text file itself. And as you could see, you just open it and it has print. Hello, world. Now I'm gonna change values again from hello world to just hello and see if it still works . I run the program go into mind. It means project double click on printing text and, as you could see it has. If it isn't printing, make sure that your outfall is closed once you run the program. Otherwise it won't work, and you'll have a blank document instead. What we're going to do now is create a small program that asks the user to enter in a word as many times as they lock until the top in the would stop in all caps. So first we were to create a user variable. Let's go on a string Tim equals and top J option pain dot show input dialogue inside brackets in tow, S T. O. P. And old caps to stop. Now we open up a while live that will keep running until the user and isn't stopped. So wow, not equals to tempt, not equals. And Rupert in the long stop and caps, we take out file. Place it in the while loop and replace hello with the uses variable in this case, Tim. Next we ask the user one small. So just copy this above Iran Code year, not including string. May we go now? When we run the program, it should keep running until the using Tizen stop, So see the top in a random would. So that's stopping a random sentence top in something else. And finally that stop in stop. Now, if we go to our text phone, we'll see that it has included everything. But when we run the program again and just top in another random sentence and topping stop , the result will be different. As you could see here, it is just random sentence. That is because print rata is over, written the text file and started a new I ever. If we wanted to keep everything that the user is written, we can then just add calmer truth. Now when we run the program twice, it should conclude both valleys, so let's top in Test one and topping stop. It's double click to make sure it has still included the random sentence from before and test one said hasn't over written any of the daughter, and we can do this indefinitely and would still keep the same values. So it stopped in, test to and stop open up in one small, and it includes all three values. So now we've created a true print writer, so it will never be over written, and I'll keep all values. And that's it for the print writer. I suggest you practice the print trotter and the file scanner together. For example, you can have the file scanners scan daughter and process the daughter to information, and then you can print the information into your text, for this is a more common program that you see today. In the next video, I'll show you how to handle the file, not found exception and a user friendly manner. 44. Try and Catch: hello and welcome to advance Java programming goals. And in this video we're going to deal with errors in a professional way. Errors are unavoidable in programming. We'll counter areas many terms in Allah, and we have to spend a great deal of time trying to fix them. However, if there is an unavoidable era and you're gonna make sure that the message displayed isn't Redlands but rather the message confirming this era, this is how you do. If this is the case, we use a rather useful method known as the try and catch statement. But the try and catch statement does is great, a bracket in which you could place a main program. And if the program cannot be run, it goes to a second set of brackets called the Catch Weight identifies the era that you have specified, and then it runs a message instead. To properly show you the try and catch statement in action, we're gonna create one in our final scanner program to begin. We top the following trying rackets, and inside his brackets will drag what we have written in the program for the grating off the SC file to the closing or Basie file, And then afterwards we had our catch open up our brackets. And in this case, we have a file not found exception. So we top that into here, file, not found exception. And then we give it's a variable name. So if is a common one and it off to that, the city of brackets way can now remove this line of the him. And as you could see, the honor eras, our program is successfully being placed into a try and catch statement. That's just need to not the rosier another to have created are try and catch. We need to have a message that is displayed if it does encounter an error. So I'm just gonna create a simple system, our print lamb file not found, and to test to see if this era works, I'm going to go into my projects folder and delete the text farm. Now that I've done that, let's run the program to see if it still runs an era. And as you can see, it has not run an era. Instead, it is displayed al era message that we created by ourselves file not found. Now I'm gonna place that takes fall back into the Projects folder and run the program again . And as you can see, it has now found the file so has no need to use the catch of the year. Although the try and catch statement is very useful when it comes to programs such as this , I wouldn't recommend using it all the time. Everest could be very helpful and helping found the problem. But in the case where you're sure there's only one top of error that you can encounter, this is probably the best method to display it. Rather than have the same area message show again and again in the next video, I'll discuss with you the project for the section. 45. Project 4 Discussion: Hello and welcome to your advance Java programming course. And in this video, we're going to discuss the project for Section three. For this project, you're to create a rather large program. Our providing of two ticks falls. One of them is called Marks TXT and the other results. Txt. What you are to do is create a project called test results. Place both of these text files into that Projects folder and then create a program that reads the Marks. Txt processes the daughter and writes it to the results. Txt. You are to do this by using a file scanner called SC Foul that reads the Marks txt, a scanner called a salon that processes the daughter in each line of the text file and then a print writer called Out File that rots to the results. Txt. The results will be a name first name a percentage and a Boolean variable name and second name represents the candidate. The double represents the percentage they got on a test. And funny, the Boolean variable represents whether they passed or not. Once you have collected and separated all this information using the scanners, you should print the results as follows the initial off the first name, the second name in the double, followed by a percentage symbol. And then finally the true or false represented, whether they passed or not. And to avoid era, you are to place your main program into a try and catch statement that displays a message. When a file cannot be found in the next video, I'll give you my answer to this project. 46. Project 4 Answer: Hello and welcome to your advanced Java programming course. And in this video, I'm going to give you my answer to six and threes project. Now, as you can see, I've really created at my program. Test results have imported the following two packages. Java, Utah and Java. Now I'm going to show you the projects folder. Here it is test results and inside of placed both text files the Marks text file, which contains the raw daughter. We need a process and finally the results, which is left blank for the processed information. And now let's begin with the code. The whole program needs to be placed into a try and catch statement, so we have to create that First open A brackets and in a second catch file not found exception as specified in the previous video, we had to create catch statement for when there's no file found. Now we have to create the scanner ISI farm, so scanner and C file equals new scanner open up brackets, new file records. Again, it's correct that records again and now the name of the text from which is mocks Doc t 16 closed off the semi cone now that you have created are foul scanner. We was create the wild loop in which will run through the text file. So while is he foul dot has next rackets open a we go. And while we're I'm gonna add the file closer outside of the brackets because once we're finished using it, it needs to be closed. Dr. Close records. See McConnell and inside the catch statement, our create a simple are Portland saying file not found. Now let's return to the cool program. Inside the wild, we create a string variable that will take the first line from the text file string. I don equals x c file dot Next lon not We have a variable that contains the first line of the text farm. We need a scan through it with another scanner. The land scanner. SCANA A salon equals new skinner one. Now, as we saw in the text file marks, everything is separated using hashtags. So we have to change the delimit er accordingly. So we have to add dot Use the limiter and inside double quotations. A hashtag close of a semi colon. Not to have the scanner that runs through the land variable we have to assign the different values to their own variables. So we're great. Available for the first name equals a salon dot Next brackets Sammy go on. Same for the lost name. A salon Don't next records silicone. A double for the monk, a salon, Dutch. Next double close to see me. Come on. And now a billing for the past, whether it's true or false, that the candidate passed out. Next, really brackets closed of a semi colon. And now we finished using the land scanner. So we close. It is salon dot clothes, and now we have to rot to the results. Ticks Farm. So to do that, we use the print Terata print Raja. It's good out file as specified in the previous video. We have to give it the name French New you file Roger Open brackets results dot txt comma True because it's going to run through several terms printing land Babylon and we don't want each land to over on the other until the last one is the only one to spade. So we add true so that where it keeps adding the values. And now this is where we have an arrow with the print writer. We simply click on the lab job and add close for IRA exception. I do not say in the previous video that you should have a catch statement for the ire exception so you can click here or you can add in another catch. I, uh, exception. I open up with brackets and you could top in a new message. Could not right to file. It's perfectly acceptable to agile throws. I exception. Yeah, I didn't mention that you need to do this, but I'm gonna do it for this video so you can just see how it's done. Found that we have written that way. Now create the print line to the results. Text file out file dot print Blanc of rap records first dot char at zero because in the previous video, I said, we really need the initial for the first name space plus the last name bus. And let's leave a tab in between the Eastern Nice mark and we need to add the percentage symbol is one of the requirements. Another tack plus the Boolean pass. So we know whether they passed or not. And finally we finish using the print writer. So we close it out file dot clothes and this is the entire program. No, I forgot. Back to documents marks unchanged. Results are still bank. Now let's run the program. It says. Build successful. Let's return to the text files. Marx is unchanged, but results now has the final processed information organized into neat columns. This is my answer to section threes project. If you find that you have more lines of curd, hopefully what you've seen in this video will help you create more efficient coding if you have the same amount of lands or less the congratulations, you have completed Section three off advanced Java programming. In the next video, I'll conclude what we have learned in this section. 47. Conclusion to Section 3: and that concludes Section three of your advanced Java programming course. In this section, you not only learned how to use a scanner, you learned how to scan from text files and to write to text files as your fund outs. In the world of programming, creating and storing information is vitally important. Writing to text files is a huge step forward and advanced Java programming. Reading from a text file and processing the daughter are essential steps towards that large step. In this section, you not only learned how to create difficult programs created difficult programs on your own. In this section, I give you only the necessary information that you needed to create a program. Everything else was done on your own. You're more than halfway through the advance Java programming course. The next two sections won't be any easier. But if you keep a cool head and practice as much as you can, they will prove no hassle. TV. See you in the next section 48. Introduction to Section 4: hello and welcome to section four of your advance Java programming course. And in this section, we're going to learn about a raise and the split method a raise, our tops of variables that can hold more than one value. You get one dimensional rays, which can hold a whole row off values. You get two dimensional raise, which is similar to a table and gonna hold several columns and rows off values. And this Congar oh, onto three dimensional to four dimensional and so on. But really gonna work with one dimensional and two dimensional raise in this course. And finally we use the split method similar to a scanner to split a string up and placed him into a raise or other variables. In the next video, I will introduce you to a raise 49. Array Introduction: hello and welcome to your advanced Java programming course. And in this video, I'm going to introduce you to a raise a raise of variables that can hold many values. Arrays can come in different tops as well into just string, double and so on. Are you creating array is as follows. This is an example off a in terrain int square brackets and in the name of your reign equals new end and in square brackets how many values you want their array to hold. To assign a value to a certain place in an array, you have to do the following a r r square brackets and the number place equals and the integer of your choice. The place system starts at zero when it comes to raise. So in creating a 10 value array, the place system will be from zero to non. This is a one dimensional arraign. You can get two dimensional race which are created as funders. Int, eh are are full array square bracket open and close twice equals new int. And then however many values you'd like to display, but this will do is create an array that holds a table of values. The first brackets contains the rose, the second the columns. So by creating an array with the values off five and 10 you're creating a table that has Favreau's and 10 columns in the next video will practice using a one dimensional arrange. 50. One-Dimensional Array: hello and welcome to Advanced Java programming course. And in this video, we're gonna learn how to use the one dimensional array. In the previous video, I showed you how to create an array. So in this one, I'm gonna show you how to use. We start with the daughter top, so I'm going to use int and then we'll give it a name. Usually it's a r r, which is the typical name for an array. Open up square brackets equals new int brackets. And how many places you want in it? I'm gonna say 10 and then close of his semi colon. Now we are going to create a loop. It'll run 10 times, giving the user a chance to enter in 10 inter jizz into each place in the array. They're fully Polgar as follows for int I equals zero. I is less than 10. The reason we don't say less than and equal to 10 is because the number place system in array starts at zero. So we wanted to stop at non and not 10. Otherwise it would be out of bounds, I plus plus, then inside, we create array and give it the value of our which will start at zero and move up till non each time the program is run equals into jail. Dr. Pass int. We have to pause it because a J option pain allows the user to input a string but not an insurgent. So we have to convert whatever into each other user enters a log, enter a number close of semi colon and that's our program. So weird on the program, it should fill the array. So now we have to create a second for loop that prints the values for and Jay equals Sarah Jane is listening. 10 James Plus plus system Our print, Um, and inside a our brackets J This program may seem redundant at the moment, but this is just to show you how the array works. You run the program, we asked you into a number, so I'm just gonna do a count up to 10. 1234567 eight non 10 10 values. And as you can see in the output box or printed neatly, this is how to create an inter Geraint and our to give it values. Next, I'm gonna show you the length field to get the length of how Maney values their own and arrange. Now I'm gonna just the four lips that early runs five terms we're gonna re of this. I have adjusted the four lip too far. So that way I really be able to enter in far values. And next, when you create a system, a print plan, an inside a r r dot length and that's it. Reason I don't add the brackets after length is because it is a field, not a method. So but this should do is find out how many values there are in disarray. So will it print out 10 for the number of places for world print out far for the number of values? So let's run the program at in our five valleys. 2345 and it prints 10. That tells you the number of places that it can home. This is very useful if you have an array that you don't know the values on, so you can sit there ray length as the eye over here, so our dot length and it should run 10 times. So when I run the program again, get 12345678 Non 10 values instead of fun. So if you have an array that you don't know the length off, be sure to use this field as it will undoubtably help. And that is the one dimensional rain. In the next video, I'll show you how to use a two dimensional array. 51. Two-Dimensional Array: Hello and welcome to your Advantage Java programming course. And in this video, I'm going to show you how to use a two dimensional arraign. First, let's create our A we're gonna use another interim in college are and now we create to square sits off brackets equals new int and again another too close of a semi colon. Now, before we asan length of the array, we have to be reminded that the first set of brackets contains the rose and the second columns. So we're going to create a four or five column arraign. Why this will do will create a virtual table with four rows and five columns. Essentially, 20 values can be held in this. Arrange an hour for importing into the arrange. This requires a special set off for lips, as in nested for lives. We create our 1st 4 leap for the roads, so that will be int l. It's gold are for a equals zero are is less than full r plus plus, and this should run as many times as the rose. And now we need to have a second for loop for the columns. So for int c equals zero, see is less than five c plus plus and open again our brackets. And now we're gonna give values to the array. So our sweet and then we top in our full Aurora and see for the columns equals and R J option pain. We must not forget to pass it that pass now J option pain don't show input dialogue, close semi column and Inter in number inside the brackets and voila, we have now created our array. And as on our previous video, we have to create an output. So we'll just copy the following of year and instead off assigning a value to this part, we're gonna print it so it's drag that into you, and that should print the values Instead, I'm going to tough in print and a new lan at the end of it. This way we can get a good idea of our values. So let's run the program again. So in each row, I'm just gonna give one number. So for the first row, I'm gonna put 11111 and then the next 123 and four, and voila! Just like that. The output isas follows in Row one a row off five ones wrote to a row five twos and so on. This is the form of loop that we use when in 14 and out. Putting our ray values. The two dimensional re is extremely useful with large sets of daughter, as in our previous project, we would have a name and an age. So now we can have an array that could have a total of three columns and however many rows . And we re Cassandra's columns, first name or last name in an age, and they all have their own separate rose. This is a great and unique way off organizing your daughter Before you put it. We weren't used the two dimensional array as many times as we use the one dimensional rain . In this course, however, I feel it is necessary that you learn about the two dimensional array as it has many users , especially when it comes to Dr Processing. In the next video, we'll discuss split method 52. Split Introduction: hello and welcome to Advanced Java programming course, and in this video we are going to be discussing the split method. A split method is a special method that works hand in hand with the array variables, particularly string arrays. What the speed myth that does is it acts as a scanner and splits up tokens in a string and a sounds and two places into a Narain. You can simultaneously use the split method and an array to create in a rain that has a specific amount of places that fit the amount of tokens in a string. For example, if you decide to split a five tokens dring, the array will have five places 0 to 4. We can find out the length of a string by using a dot length method. Bet by separating a string into tokens into an array, we can use the dot length field to find out how many words are in a string. This is how use a split method and an array simultaneously. String square brackets they are, are the variable name equals and the variable that you decide to use. Let's say it's T G for string dot split open brackets and inside here you choose your day limiter. This could be the hashtag or space. For example, we'll use a space close of his semi colon. Let's say that the string SDG has this sentence as its value. A random sentence. This means after the land with the array and the split method, the rain will have a length off three places for three words and one of our previous programs. We scanned a document with a name hashtag lost name hashtag an age hashtag and true or false, we can use this split myth it to split each land into its own roe in a two dimensional arrange they about organizing and processing Doctor. This, in the end will help save on lines of code, creating a more efficient program. In the next video, we'll practice using the split method. 53. Split Practice: Hello and welcome to your advanced Java programming course. And in this video, we are gonna practice using the split method. First, we're going to create an example. String variable for us to split. So let's say string sent sentence equals. This is another random sentence close to see me. Come on. Next we create the array that we're going to split it into string brackets. They are equals. ST got split, and we're going to split it on the space. Does it seem you go? And now we're gonna print the length of the array to see if it works. Say, are dot length and no brackets because it is a field not emitted. Now let's run the program, Prince far. And as you can see, they are have words or tokens. But you needn't split it only on a single character. You Canosa split it on a word. So, for example, we take is from the program. It says there are three characters. Let's because is appears. Plus, first is over. Yell second Over here they've are splitting it into three Turk ins, the th the space and the race to the sentence. Suppose we wanted to specify which is like a single is on its own and up and is in this well, you just endure spaces or in the program, and it splits into two, completely removing the spaces over here and leaving another reign of sentence. And this there is not much more to the split method. However, It's better to keep in mind that using the split method with a string array is much better than splitting a string of inter jizz into an inter array because there's no guarantee that it's going to be an intelligent, so based split it into a string array, then convert the string in the array to an integer. And this is the split method. In the next video, we'll discuss the project for this section of the course. 54. Project 5 Discussion: hello and welcome to advance Java programming course. And in this video, I'm going to discuss the project for Section four. For this sections project, you're to make use off a raise and a split method. What you're to do is ask the user to enter in a list of sports person plays and place the results into a string variable year than to ask the user for another set of sports and placed them into another string variable. You must then separate these different sports into a raise. To do this, you must use the split method. Once you have split the results into their different to raise, you are to find out which student plays the most sports and the way you do this is with the length field. In this if statement, you are to state which student has played the most sports and to display each sport on a separate line. In the next video, I'll give you my answer to this sections project 55. Project 5 Answer: Hello and welcome to your advance Java programming course. And in this video, I'm going to give you my own certain section force project. Now, before we begin, we have to create our project. It's a click new project job application, and we'll call this one split and a rain. And now we're going to import the various packages that we need. In this programme, we only need one, and that is a job. X wing package says we are going to be asking the user to enter in values, so import Java ex dot swing dot star clothes a semi colon. Now we begin coding. The first thing we want to do is to create the first string variable, but the user is going to enter the list off sports into so string and let's go to s one. For sport, one equals J option pain. Don't show input dialogue. Open up your brackets and top in the message you want to give the user So in tow the list of sports for the first sportsman. Close a semi colon and now I'm going to move straight onto the array for this 1st 1 string . It's great brackets and it's called a Are one equals And now we use the split method. So s one dot split and we're gonna have spaces. The user will be able to intern their sports and the space between each one. So this will be the best choice to use. Next we great Another one for sportsmen number two So string it's too Giap Shin Pain The martyrs will copy this line of go to be him and just change the sportsman value to second Next, recreate the array for sportsmen number two they are too equals is too not split And again , the space character. Now that we have not only import to the daughter but also processed it we're going to now output it So if they are one don't length is greater than they are to dot length This is so we could find out which sportsmen has played the most sports. We didn't have variables for the a r one dot lengthen a are two dot length reminders will just use them directly. Now we create the output. Lon Uh first sportsman plays the most sports and inside were going to have a for loop, so full int equals zero I is less then a r one don't length close of silicon plus plus plus plus And inside the full IP, we will print each one a one I And now we create an else statement way we will have the exact same but for a r two seconds, sportsman. So we changed everything accordingly. Second instead of first and a are two instead of a on one. And now we run the program to test to see if it works for the first sportsman. I'm gonna anti in three sports such as golf, tennis for rugby and click OK, And for the second sportsman, I'm gonna only intend to just golf and tennis and click OK. And as you can see, the first Sportsman is the correct answer. And it does display all three of e sports right there. Al Attar on the program again to see if the second sportsman or work so golf, tennis goals, tennis, rugby okay, and the second sportsman plays the most ports and old sports. Are they? So that is the complete program A very simple program on the face of it. But you got to make sure that you don't have any unnecessary lines of code and, as you can see, have simplified that by excluding any unnecessary variables. If you have the same amount of lands of curd as I do, or less the congratulations, you have completed Section four's project. In the next video, I'll conclude this section to the course. 56. Conclusion to Section 4: Congratulations. You have just completed section four of your advance Java programming course. In this section you learned about a raise, a very complicated formal variable that can hold many values. However, it is extremely useful before continuing with the course passages practicing what you've learned in this section of what you've learned in the other three. Start by using the scanners and their race together. Process daughter using the split method instead of the land method. When scanning from afar, you'll find that it is easier to split up or your daughter into an array than it is to use a scanner and use separate variables, Not to mention it saves on lines of code, creating a more efficient program. The split method and a raise will no doubt come in handy in our final section of the course , where we begin object orientated programming, which involves creating your own methods in classes and then using them in the main program . See you in the next section 57. Introduction to Section 5: Hello and welcome to Section five and the final section of your Advance Java programming course. In this section, we begin object orientated programming. In this section, you will learn how to create objects. We create objects through classes, and in these classes you have several different methods that you can utilize to solve problems. This is the goal of object orientated programming to create your own classes with your own objects and methods that you'll be able to use in the main program. The myth IDs you'll create will be very similar to what you have done throughout the course . Such a scanners and the processing of data. The useful factor that comes into object orientated programming is that the classes that you create contain methods that can be re used over and over and over again. In other words, you need intact to write the same code several times. For example, you needed to create another scanner. When you've already created one in your class, then you can use this scan a method to help you scan files again and again without having to write the same code. Throughout dissection videos will be focused on creating classes and objects as well as variables in those classes and methods. The project at the end of the section will require most of what we have learned throughout this course. In the next video, I'll discuss with you how classes work. 58. Classes Introduction: Hello and welcome to your advanced Rob. A programming course in this video we are going to discuss class is the best way to describe classes is by saying that they are set off methods and fields that you can reuse in your main program. For example, the scanner comes from the utilities class. By importing the entire class, you're basically giving your program the power to use these objects, the scanners to your benefit. We're gonna learn how to create classes and two different forms off methods that you'll be able to use throughout the section. The first is avoid method. Avoid method doesn't return any value, however, does change. Daughter with second miss it that you learn is known as a top method. In other words, it will output something. So, for example, if you creates a string message, it will output a string. A good example of this is a split message we used. It outputs a string arrange. Some methods do require daughter from the main program, for example, the split method. Once again, it does require from you a string, be it a single character, string or whole word that is used to separate tokens this string that it requires from you is taken directly to the class and then runs a program on the variable that you have selected and then outputs following as a string array. This is the top of Mr that. We will learn how to create when creating emitted in a class. It does require to make a separate program, for example, and our main program. We have the static void main program, but in a class you can have several, you could have a public void. You can have a public and then a top visits of public string and so on, so you can create several methods in a single class that it can be used for your program. They are many programs that use many classes. We ourselves have you made programs that use many classes that were to import. One of our goals is to create a reusable Kloss that has methods that we can use multiple times in the next video. I'll show you how to create your own class in your own program and create a public miss. It 59. Void Method: hello and welcome to advance. Drove a programming course. And in this video, I'm gonna show you how to create your own class in your own program. First, let's great our program. So it's a new project Java application. And let's call this 10 P. Practice like finish. Now that we have created our project and main program, we go over to our package over a year just above the main job application, right click New and Java close. And in this class, religious court, the print class because we're just gonna get it to print lands for now. And this is our class. This is where we're gonna rot our code for our reusable methods. It's a simple as that. And before we leave the video, I'm going to show you how to create a short print method. We first top in the following public void, and I'm gonna give it the name off droll. We didn't have our brackets and we're open up our curly brackets which will contain the main code to our method inside. I'm just gonna have a simple system, our print lamb and top in the following. This is a random sentence and just like that, we have now created a simple method. We can now go over to our main program by either double clicking here or just clicking on the tabs. If you haven't closed in yet and we can end the code to use it, we first take the name off. The class would just print next. We top in a variable name. So let's just give it a name like Lan equals new print brackets closer to semi Colon. Right now, we have just called our method print and given it a variable name off land. And now that we've called the close, we have to use one of its Mase. It's so I'm going to use Lan the variable name dot draw and close the semi girl and now we're gonna run the program. It goes into the class, and as you can see, it uses the draw method as it has just printed. This is a random sentence from our Method public void draw, and that is our first message. We've already taken the first steps into object orientated programming by creating a print object from the class print and using a message land dot draw in the next video real practice, creating more complex methods 60. Typed Method: Hello and welcome to your advanced Java programming course. And in this video, I'm going to show you a more complex form off method. Before we begin, I'm gonna first create the project New Project Java application, and I'm gonna call it name processing. I think it's about time I show you how to properly name your projects because up till now it hasn't been necessary. But to properly name a project in a class, it is better to have them as a single word. But for now, we need a knows. We're naming your class. Variables or project always begin the first world with a lower case and the second or and their own within abdicates. Its are click finish. Now that I've created my project, I'm going to create a class that we're going to create a method in so right click New Class and I'm going to call this one the process class. So process Capital Peake. And now I have created my class. I'm going to begin creating my methods. And the message that I'm gonna show you now does require you to have variables given in the main program. First, I'm gonna create the maze it so you can see what it does and what variables that we require and then in the main program will input those variables, so that way it can use them. So let's begin public string and this one I'm going to call it process name and in brackets a string name. And this is what I'm going to output. So return name. Now that I've done that, it is now returning a string, as I've stated in the buff public string process name. So it has to return a string. I'm going to top in the following, which is processing over the name. So let's say a name gets entered the first name and a surname. I'm gonna have a small program here that will take the initial the first name and then print the second name. It is simple enough. We creates a temporary string variable equals name dot char it zero plus name dot sub string and inside name dot index off and space plus one closer to see me go on. And that should processed the name perfectly. So that way it prints out the first initial and the last name has just add a full stop in between them of this space, so it's much more neater. And now real return temp only Lift named this that way it wouldn't shown era while we've created our code. Now that we're returning the actual complete value, we can go to the main program over yeah, and begin our object creation. So we just call the class name process that's giving a burial name. So I'm going to say name equals new process. Now that we have created our object, we need to create a way for the user to enter in a name so that strength Tim equals J option pain. Don't show input dialogue. And, as you know, we're going to have to import packages. But for knowledge is top this in inter a full name, and we'll add the package the quick way by just clicking on the La Baule. Sir. Knowledge we have crazy al variable. We need to process it. So that's great. An output for the result and call al object name dot process name. As you can see, it has a really detected that message for us. So it does know that there's a close and it is a way off our method, and inside we'll have temp. So now when we run, the program is checked to see if it processes and name. So it does ask us to Internet name. So Joe blocks and it should now print j dot space blog's. And it does, indeed, and this method is reusable so we can take this same lahm and paste it several times as well as the output. So what we have now just done is created a reusable miss it. So let's run the program again. Joe Blocks and Steve Bill a spill. And as you can see, our results are working just as we hoped. And we can simplify this code even further, but placing these two lands into a wild lip that will continue to run until the temp variable equals stop. In other words, we have created a reusable class that will continue to run until we say stop. This is a far more advance mated because not only doesn't require you to enter in a variable, but it is also a top method that returns a top of variable. In other words, a string. So that's another two steps in the right direction with object orientated programming. In the next video, I'll show you how to create profit variables personal, last and only used by the programmer in the class. 61. Private Variables: hello and welcome to advance Java programming course and this video. We're going to be discussing private variables when it comes to classes. We work with two tops off variables, but these are not doctor tops but actual tops of variables. These two are private and local variables. Profit variables are variables that cannot be changed in the main program. To create a private variable, you go to the beginning of your class, and instead of opening up method, you top in the following to create a profit into Joe Profit int num closer to see me coat on. What makes this variable profit is the fact that it can be used throughout the class in different methods, not just public string, but let's say another method blow and an element it and so on and cannot be changed except by the programmer. So the user, him or herself cannot affect this variable, however, and these variables will be here. The user does a victim, so this is the other top off variable. There are local to a specific object or method, so as you can see how the name variable and the temp variable are only local to this Publix Drink process Name method. However, if I want you to use it anywhere else, it would showed era because this variable has not being created it in this way, it's sort of like an if statement if the if statement does not run the else statement, whatever happened in the else does not exist. So even if this method is run its variables or only a part to this method, I cannot create an animated using this temp variable without creating a new one entirely. Private variables are extremely important to any company programming. These top of variables that can only be affected by the programmer come in handy when the user does effect the daughter in a large way. So it's best to have the programmer have more control over he's program, then the user. What I'm going to do now is create another public method that does output daughter, but in this case it will put the integer numb, private variable I've created over again notice. I did not have to create a number very born inside this method. I did not call for another variable from the user. I'm just printing the prophet variable that has really been created in the class, the variable that can be used and every method up to you. And I'm going to top in the following name. Dutch numb print, close of a Simic on. And now when I run the program, it should print no. And it does indeed. Now I'm going to give numb value, so I'm gonna give number of Random Valley off. Let's say five now, as you would assume when it returns numb, it should print the number five. However it does not. When the run the program again, it's still prints. No, this is because this is a privatized variable. It will not be displayed by user in any way. So when I run the program whatever code I have displayed in the main program, it will not show watch a profit. Variables values because it is profit to the specific class. This is a very useful top of variable when working with the user, because it avoids what is known as Giger gr JIA, which means garbage in garbage out. So this way you can avoid the process with the user inputs Aylon off daughter that cannot be processed this way. Variables like this could have a default to avoid such an era Profit variables may not be printed in the main program, but you can still use them to affect the result off doctor and other methods. So be sure to use product variables as often as you can as this gonna help in the future to avoid any errors that may occur when using values imported by the user. In the next video, we'll be creating scanner methods. 62. Scanner Method: Hello and welcome to your advanced Java programming course. In this video, we're going to create a scan omitted. And to help save Tom, we're going to reuse the code from our file scanner project. Let's start by creating our class the right click on the package of a year like Java class and give it a name off scanner like finish. Now that we have created our close, what we're gonna do is go back to our main program and copy the entire code over young. Go back into the close and create a method called file scan and place the code inside. So that should be public void. File scan. And inside, I'm gonna add one string variable and that'll be the file name, string, foul name. And now that I've done that, I'm gonna paste the code into the And as you can see, it's asking to import the same packages required. You must click. Okay. It'll help save Tom and rather importing in by end again. And now that I've pasted the code into this file over here, I'm going to take this quotation marks contain names dot txt and placing. Found him. Now that I've done that. I've created a reusable message that can be run many terms varying on the different files that are contained within the Net. Beans, projects, folder, file, scanner. So if I go back to my main program over here, I can out top in the following way. I create my scanner object by scanning. Test equals new scanner. Closer to see me, Colonel. Now, I'm gonna ask the user to input into a string variable, and I'll use this string variable with my method file skin, and it should be my foul name in this way. Ask the user which text file they want to be skinned. So string temp equals J option pain. Don't show input, dialogue close of a semi colon. And inside, I say, what is the file name? And now that I've done that, let's use our method test docked and file skin with the temporal placed inside. Now let's run the program file. Name is names, Doc. Txt. Now we're gonna run the program. As you can see, the results are all printed and this is all things to our method that I created inside the scanner class. Traditionally, you wouldn't use scanner or any other methods or object class names inside your own classes , it's much better to create your own name. However, this is a very short method I wanted to show you, and it is simple is that we have now created a scanner that asks the user to enter in a found him. And not only that, but once you have entered in the file name scans and prints. The result all in three lance. In the next video, I'll show you more complex program containing a class with many methods, including a file scanner and a two string method. 63. OOP Practice: Hello and welcome to your advanced Java programming course. And in this video, I'm gonna show you more complex way of using objects and object orientated programming. As you can see, I have created a project called Object Practice and created a class called Read. What I'm gonna do is create a clause that contains three methods that recon use to read a text file, process the daughter and output it. I've provided you with a text file. Court roster, Doc. Txt. And as you know, when it comes to reading a foul, you go to your Net Beans Projects folder and you place it inside. And as you can see, the roster dot txt Foul as the following daughter. A first name, a Sunni age, an agenda or separated with white space. What we're gonna do is great. One mated that will read the text file and place the daughter in June Array. We'll create another mated that will process the daughter from that array from Joe Blog's 27 male to J dot space blog's space 27 Space M. So I only initial the first name full surname, the age, and then only the first letter off the gender. This is the output that we plan to print. Once admitted as completed, processing all of the daughter we're going to great in output method that output the result . All of the work we're gonna do is going to be in the class Read that I've created here. So let's begin coding. First thing we have to do is import the packages we need. And as you know, when reading a file, you have two main packages that you need to import. You need to import the utilities package, so import java dot util dot star and need to import the Iot package input java dot io dot stop. This package contains the code that we need for file not found. Exception. Because when we use a scanner that scans files, we need to use a try and catch statement in case the file is not dead. E g. The file not found. Next, I'm gonna create the prophet variables that we're gonna use throughout the program First private string array that's going to contain the values now, since we cannot know for sure how many values on a text file to lengthen the array we add in a large number to the array, so I know it's less than 100 so I will atop in 50. Next we create our sick and probably able, which is account variable that we in the years to keep track of how many places that the values take in the array. This way we don't have to print several blank spaces with his left over so profit int count equals zero. This variable will make more sense later on. And next we have a string that will contain the result. Private string result equals and let's leave it blank. Now let's create the shells for new methods. First, we create a public main method for look loss, so that would be public read. And inside these brackets, I'm gonna ask the user for the foul name so it does require a string variable string. I found him so the user can select which text file they want to scan if they all many. Now that we have done that, we create a try and catch statement try, which will contain the code for reading a file and now the catch final not found. Exception E. And then we have an output Mason, Shane found have found It shows an era now, But this hero go away once we add our file scanner. So scanner SC file equals new scanner, new file and finally file name close of a semi colon. As you can see, the areas are really disappeared. Now we need a while loop that will run through the file adding values to their rain and adding very to the count so we can keep track of how many values they are in the rain. So that will be while s e file dot has next and inside the loop, they are our count. And it's starting at zero and will increase as we go along a c file dot next close of a semi colon. And now we had count plus plus so add as the count goes along and now we finished using the text far. We've populated our ray, so we close with s e file dot clothes and end of a semi colon. Now we create our second miss it public void process over my brackets and there we go. In this method, we're gonna process the doctor to print the result. So we create a four loop that will run through the arrange for into R equals zero because we want to start at the first place in the array. Which zero? If you know your number, pay system, I is less than count I plus Plus, what we need to do now is create a scanner that will scan. Aylon was at the moment in that array place is one line of text and serve a single token each. So we need to separate there's lands into tokens and then organize them and process them accordingly. So scanner I don equals new scana and inside the brackets, we have our I. So our first Valley is gonna be selected, which is if we go to our text file and have a look. Joe Blog's 27 Male. So we need a process that daughter into Jane Blog's 27 a. M. So now we need add those results to the result. Variable result equals result plus because we also want to pass values stored into result. So we had this Lenya Basilone don't next to get the next ring and then don't charge at to get its initial zero plus well stop space plus a salon. Dr. Next which will get the surname. But we're not affecting that daughter in anyway. So we move on to the next one, bless the space, plus a salon dot Next, and we still not affecting that. So we move on last space, and now we need the first letter of the gender. So again, it is a salam dot Next records don't Charente and inside zero. And of course, we need it at a new learn afterwards. So that's back slash in close with her. See me? Come on. What we're gonna do now is Khloe's are scanning because we have not finished using it s Ilan, that close brackets semi colon and that is our second method. The process method no, we have to do is create an even smaller bases. They are to put method that'll print result so public string because it is returning a string print result and return result. That's all we need. We have now completed our class containing the methods that we're gonna use an online program. Now if we go back to our main program, we can start by using our methods first. Let's ask the user for the text file Name String name equals J option pain. Don't show input dialogue and inside enter in the text files name closer for semi Colon. Of course we need to import are swing package. So I'm just going to use a short cut for now. Next we call our class read by creating a read object. So read and it's the school. A taste for now equals new freed and as you know, it needs a very bull string and that'll be name close with this semi colon. Since this section over here is the main part of the class, it will run without us having to call it so by simply creating a read object. It has a really gone through this try and catch statement. So we need to move on to the second method, the process method. So we top in test dot process close of the same weaker on brackets and now we just need to output. The result system are printed on test dot print result. And that's all entire program. Let's run it to see if it works. So it's now asking us for the text files name, which, as we know, is Rasta doc T X t we click. OK, and as you can see, it's processed Our daughter. It has the initial of the first name has the second name, age and the first letter of the gender. So our program and its methods are working correctly. And this is object orientated programming. You can create several classes that could work alongside each other. But for now, I think one has just done what we needed and we can leave it here. In the next video, we will discuss the final project in this course. 64. Project 6 Discussion: hello and welcome to your advanced Java programming course. In this video, we are going to be discussing the final project for the schools. You are to create a project called Object Processing. In this project, you'll have a main program and a class. In this clause, you have four methods. The objective off this class is to scan a text file, process the daughter and displaced certain values. In your first method, you are to read from a text file which are provided for you. The text file is called final dot txt. What it reads from this text foul should be stored into an arranged The doctor in this text file reads as follows a name, a surname and an age separated by hashtags and your second method. You're to look through this daughter and found which name has the highest age. You are going to display the full name as follows. The first name, the surname and the age and a message telling the user that this is the oldest person you're through. Admitted should scan through the array again, but this time process the daughter and display them in columns as follows. The initial of the first name the initial second name and the age. And finally, your fourth method should process the daughter and writer to a text file again, which are provided to you called final Result. And the results should look as follows the name and surname and age off the oldest person to blank lands and in the process daughter, the initials and the age listed below off every other person, including the oldest. In the next video, I'll give you my answer to this project. 65. Project 6 Answer: Hello and welcome to your advance Java programming course. And in this video, I'm going to give you my answer to Section five's project. Now, as you can see, I've created my project charity object processing and the class read. And of course, once I finished creating more project, I placed the two text files into the Projects folder final, which contains the raw daughter that we need a process and final result, which we're gonna rot our results to. Now, with that out of the way, we begin coding we're gonna start in the read class. Were first gonna import the various packages we need because we're gonna be reading and writing to file. So we need to import the utilities package import java dot util dot star Sammy going on, and then we need to import the Iot package jacked ioo dot star semicolon. Now that we have finished importing the packages we need, we need to create our private variables that we're gonna use throughout the class. We're gonna be using account variable int count equals zero to keep track of the places in the array and the array profits string. They are square brackets equals and new strength. And once again we don't know for sure how many results can be in a text phone. So we take a large general number such as 50. And then I'm gonna add the two string variables mentioned in the previous video that the oldest person will go into oldest equals and leave a blank and the final results aural the finished daughter will be placed into results equals and also blank. Now that we have created our private variables, let's create our first method, and it's gonna be the main method you can also use avoid method in this place. But I prefer to get the first method done and out of the way the moment you create your object. And to do that, you make it a main method. Instead of using public void read, you just call it public. Read the name of the class public re and a string for the foul name that the user is gonna input. Now that we have done that, I'm gonna create a try and catch statement that will contain the scanner that reads a text file final dot txt. So try open brackets before place Makudi in. I'm gonna create the catch file, not found Exception e and inside a small message saying could not find final. It does Suren era, but that goes away the moment we create the scanner. So let's do that scanner is he filed equals new scanner, a new file file name because we want the users file. And as you could see, the error is gone, and we're now have our scanner. Now, we're going to start taking lands from the text file and placing it into the array. So we create a while loop while SC file dot has next open up on brackets and now we start taking the varies and putting them into the array. They are count, which will start at zero, which is correct because a raise number place system starts at zero a. C file dot Next loan. I want the entire line placed inside the array count plus plus. So that way, the next value will be added, will be in the array place number one, and when I would be finished using our file scanner, we close. It s e file dot clothes, and that is our first method. Now we need to create how sick and method this is. The find oldest method that we're gonna be using someone a court public void find old. Now, this myth it is going to be used to scan through the array and fund the oldest one. So we're gonna have to use an if statement and compare ages. So let's create a base age to start with and old equals zero. And now let's create our for lube for int I equals zero. I is less than count I plus Plus, this should run through the array for us. Now we create a scanner scanner s Ilan equals new scanner. And let's just give it the value off a rain number are which will start at zero, which is correct. And we need to use the d limiter hashtag because, as we saw in our file, we go back to final dot txt. Everything is being separated by a hashtag. So we need a you change the limiter from what space to hashtag, which we have just done close of Simek along. Now let's create a temporary variable f'ing tim equals s Ilan. Don't next plus space plus a salon. Not next. This should get the name and surname off the oldest person in the rain. And next we creates an integer variable into numb equals s salon, not next. And to get the age closer to see me. Come on. And now we finished using our scanner. So it's salon Dutch close brackets. Seen your column. And now for the if statement for comparing the age numb to the airbase, age old. So if numb is great in old and this is where we use our prophet available oldest First, we're gonna change the old to numb, since that is the new vetting. Next, we're gonna take the oldest and change. It's fairly from blank to the temporary variable we created. Yes, the age which is now old us A small message saying that this is the oldest person is the oldest close of a semi colon and that is our sick. Admitted out of the way the fund old method and now far so admitted the process method which will process through the rest of the array and organized all the results into two initials and an age organized into neat columns. So public avoid process. Now we use a for loop just like before And another scanner full into our equals. Zero eyes listing Count I plus plus and a scanner scanner issue. Lon, it was new Skinner. They are. I Dr use the limiter hashtag. And now we're gonna take the results, process them and place them into the results fable. So results equals results. Could we want the previous ones as well? If we do not include this land, it want to include our new information or old. So results equals results. Plus a salon dot Next, that should get us first name. But we only need the initials so dot char at zero plus and full stop. And let's put a tad in between each of these values Press a salon duck next. Don't char it. This should get us our surname. So another zero to get that initial. Plus full stop back slash t to get attempt. And now we needed at age plus s Salam don't next and brackets plus And now we need added fresh Nealon. So it's backslash are backslash in close with a semicolon. And now we finished using the scanner. So s Ilan, Doctor, Close. And that should run through the entire rain adding more more values to the results variable . And now we create our final method. The method that prints the process results to final results dot txt, which, as you can see, is blank. So it needs daughter. We create our print to file method as follows public. Avoid print to file Print e file would be a good name for our message. Now we create a try and catch statement just like before. But this time it's did have found find. Exception are catch will be io exception. So I o Exception e and inside, and May said Shane could not write too far. It's better to have a different era message than the one we used at the beginning. This way we can know where our era is. If we had the same one, we don't know if the ERA isn't finding the file or writing to the file. And as before, it has an air of message here. But that will go away once we created elopement. Rata print Rato out file equals new friend Trotta New file Roger and inside. We want to put it to the final results. Txt final result dot txt close of a semi colon and now we need a outfall dot print lon oldest As stated in the previous video, he was print the oldest first and then to blank lands in between. So backslash are backslash in backsides are back slash in bus results analogy finished using the printer outta. We, of course, have to close it out foul dot clothes and at a semi colon. And now we go back to our main program and we add the Kurd necessary to call our read object and use its methods. We first asked the user to enter in a foul name and to do that, we'll need the swing packages. So import job x dot swing dot star and now back to our code string name equals Shea option pain not show input Dialogue inside in tow. Name into name off text file close of a semi colon. And now we call our object. Read read. It's called test For now, test equals new read and we plug in our variable name No errors. So that means it has now recognised object. We know you start using our methods test dot Found old is the first test. Dr. Process is the second and finally test dot print to file. And that is our entire main program. Five Lines of code. We now run the program top in the name of the text file, which is final dot txt. Click OK, and it says build successful After eight seconds, let's check our projects folder, open up finals and yet final results. Txt has are organized daughter. It has the oldest name as well. Frank Tom, 99 is the oldest, and everything has been organized into neat columns and the initials. And if we look over here, here's if t 99 Frank Tom, Just like I mentioned in the previous video, we have to include the oldest, and this is our project. We have now finished the project per section five. If your program has the same amount or lace lands occurred than Mom think congratulations. You have completed your course in Advanced Java programming in the next video are conclude what we have learned throughout this course 66. Conclusion to Java Programming: Learn Basic Code for Beginners with NetBeans: and that concludes your advance Java programming course. At the beginning of this course, you started out by learning many methods that have been really made and programmed into the Net Beans rd. By the end of this course, you not only learned how to create classes and objects that create your own methods as well . By applying many advanced techniques, you're able to master many sections of programming that many struggle with. Programming only gets more complex from here. Here is a popular programming quote, as often used to describe the intricacies off programming. Programming is logical creativity. In this course, you have learned how to use many tools now, tools that you can use to create programs and other intricate algorithms that can no doubt be of use. There is so much more to learn in the world of programming, but hopefully this course has helped you along your way. Feel free to use this course as a reference guard whenever you find yourself forgetting what lines of code to use. Thank you for taking my calls. I advanced Java programming with net beans