 Hi, I guess I'm going to do a mini lecture about some style things that I see when I look at the first assignment the introduction to Java. Let me share my screen here. And as I have here is my template file, which I'm going to use as my starting point. And let's save this under the name blank lines dot Java because what I want to talk about is printing about blank lines. The purpose of the program. And they get to get different methods of putting in blank lines in the output of a Java program. And let me pause the recording for a second here. So let's just have a few lines of text here. And I have to make something up here, I guess. Well, let's say we're doing an advertisement of some sort. We have quality widgets for sale. And then the next line will say, check out our great selection right now. And because it happens to be Labor Day, I want to put in a blank line before I put out the word system dot print line PS. We have 10% off on our Labor Day sale. And once I put a blank line here in the source code, will that produce a blank line in the output? And the answer is no, it will not. How do I know? Well, first of all, I've done this before, but if you didn't know what you do is you simply compile compile it. Oh my goodness. I have. Well, there's my error. I guess that's not going to work. The problem is remember I changed the name of this to blank lines dot Java. So this has to be also called blank lines. This is a mistake that I am consistently making. So this is probably not the last time you were going to see me make this error. That's my personal bad my personal error. Now let's see what happens when I run this program. And there's no blank line in the output. It tells us that blank lines in the source code do not correspond to blank lines in the output. The way we do it is by saying system dot out dot print line with nothing in the parentheses, and that will give us a blank line. I'm still going to keep this in here. I could get rid of the blank line but now it looks a little bit messier. Keeping the extra blank line in the source code, even though Java doesn't care about it. I do because it makes my code more readable. And now let's compile that. And now we have our blank line before the 10% off sale. That's one way to do it. This is the best way to do it. One of the other ways that I have seen and one of them is people will put the empty string days as well. There's got to be something in between the parentheses, or in fact they'll print a blank, because blanks are invisible on output, and that works. There's nothing wrong with it. And again, you can print the empty string. And that'll work too. But both of those are unnecessary when this is probably the least amount of typing that you have to do. And it's still very clear what's going on. So that is what I would recommend. The next thing I want to talk about is something called escape characters. I am not sure if the book talks about them, but let me do a quick review of that. And I need to pause the recording again for a moment. And the backslash in Java is called the escape character. And you use it to make non special characters into special ones, and special characters into non special characters. For example, let's say I want to say print line of this isn't a long sentence. There's no problem here. I have a single quote inside of double quotes. And that's perfectly okay. That's what I want. Now though, what do I do if I want to say something like this? He said hello to me. Now I have a problem I have this quote mark will end that quote mark. And this quote mark will end that quote mark. But now the word hello is in the middle between them. So what's going to happen because I now have such a too many quote marks and the answer is you get an error message from Java. How do we correct that? The problem we're having is that double quotes is special. To change the specialness. I'm going to escape it. I'm going to print line. He said, and then I'm going to go to backslash and a double quote. That's all Java. No, no, no, no, no. Don't treat this as the end of the string. I really want an actual quote mark in the middle of this. And then we need another one just like it saying no, no, no, no, no, don't end the string yet. I want a real honest to gosh double quote. This one doesn't have a backslash and it is going to be the one that closes this opening one. And that's how you can put double quotes inside of a double quoted string. So that's where again as an instance where backslash took a special character and made it unspecial. There's also backslash and and is an ordinary character. But when I say backslash and it takes on a special meaning, which is to put a new line between ABC and 123. And also the tab character, which is backslash T that puts a tab between ABC and 123. Now the question is how many blanks is that it turns out on my system I happen to have it set right now to four blanks, but that's up to the user. The user can set the number of blanks that they want for a tab. So some people might have it set to two spaces some people have it set to eight spaces some people have it set to four spaces, you cannot rely on what the output of backslash T is going to look like, because it all depends on how the user has their system set up backslash T I don't recommend using. And I'm going to recommend only sparingly using backslash and so let's talk about some of the problems that we run into when we use backslash and let's save this as blank lines to. And so what some people will do is they'll say, okay, print LN would automatically give me one new line. So I'll put a new line character that will give me go to the next line and go to the next line again which gives me my blank line. Isn't that clever. And in fact, if we compile it and run it, we get exactly that what we want. So I'm going to put a comment in here and use backslash and to generate extra blank lines, but I do not recommend it. It's somewhat, I guess I call it invisible. And if you aren't looking carefully you won't see this backslash in here if you aren't looking for it. So backslash and can escape your notice that can. No pun intended can escape your notice at the end of a string, a separate system that out about print line is much more noticeable. And this is where people abuse new line. And let's go and save this under a different name and let's call this bad new lines dot Java. This is an example where using backslash and too much makes an unreadable mess of your source code. Let's say I want to talk about the address for overgreen Valley College. So I'm going to say here evergreen Valley College backslash and 3095 Europe a point of road backslash and Santa's a California 9 5135 backslash and 408274. I think that's the right number phone number and another new line and then HTTP as console. So I've got this gigantic long line. And because I'm using backslash and to get my new lines. When I print it out. Oh, doesn't that look elegant. Yeah, this works but I don't consider it to be a good way to do things. But I'm dividing line here. I would much prefer to see you do it this way system dot print line. Now you're saying oh if I've got to do a separate system dot print line every single time isn't that going to take a long time. Well one thing you can do of course is use copy and paste which in this case is control V. And then I can have here. 395. Taste it in. Oops, I'd better put it. I'd better put in the quote March. Hey, what would happen if I left the quote marks out. Would that cause a syntax error or not. That's a good question. I'm going to let you, why don't you pause this recording to pause the playback and think about what is this going to do. Is it going to give me a syntax error is the compiler going to complain. Is it going to crash when I run it, or will the program do something that I didn't really expect. What do you think is going to happen on this. Well, let's see if the compiler likes us compiler doesn't complain. But watch what happens when we run it. It gets us negative 7766, because that is 408 minus 274 minus 7900. So in this case we do need the quote marks run it again after compiling it, and the output looks exactly the same for both of them. But if I had to edit this let's say the phone number changed. This would be a little bit more difficult to keep track of everything. But here because each item is on its own separate line if I need to make a change to only one line. It's fairly straightforward for me to find which one it is and make the change. Let me put a comment. And to make one gigantic. Instead. What I'm going to do by the way at the end of this mini lectures I'm going to zip up these files and upload them to the files area. I'm going to put a folder in the files area. Let me go back here and show you where that is. In fact, you go to files here. Under example files. I put in a zip file for today. And you'll be able to download these this file for your own convenience. That's pretty much what I wanted to talk about in terms of blank lines and style. Again, I like to put in blank lines in my source code to increase readability. I'm going to do a quick pause here and check out some other things there maybe some other. There may be something else I want to cover and I want to check what it is. Oh, it turns out I already have these style hints for the introduction to Java program. And I talk about print line versus backslash and so everything I've been talking about here is exactly the same thing that you're going to see on this page. And also about spaces and calculations. And why you probably should not use the backslash t character. So everything I've been talking about is duplicated here except for spaces and calculations and always put a space on both sides of arithmetic operators. So instead of, it's a little larger here, something like this formula, which is really difficult to read. We give our calculation more breathing room by putting spaces around the operators. If I see errors like this in the first one or two programs no big deal. But after the second or third program I'll expect you to follow that part of our style guidelines, and I will take off points for that. Because I'm an incredibly horrible person. And let's see what else do I need to talk about here. That should do it for today. So that's our mini lecture, and I will see you all online at some point.