Printing To The Console

3 minutes
Share the link to this page
Copied
  Completed
Java Console is a simple debugging aid that redirects any System.out and System.err to the console window. It is available for applets running with Java Plug-in and applications running with Java Web Start.

Transcript

Hello, in this Java tutorial, we are going to look at printing to the console. If you already watched the one of the set of videos that I already did for Matt liner, Windows or just running code in a online ID, you would have you know, already seen printed, I didn't quite explain it man was more just to make sure that the project was set up correctly. Also, no thing even though I'm, you know, coding this and doing this video on a Mac, it doesn't matter what you run the code is the same month you set up, it'll be fine. And that's the same with all the code in this series. Okay, so I'll get rid of this. And printing to the console is really useful, especially when you're debugging your testing stuff.

In a real world application. You probably won't do it unless you're creating some sort of console based application, and then exactly more for relief than just for debugging. Whether the night is These are great for testing. So you do system dot out. So this is saying that, you know, you are accessing the output stream or things once you have the standard output stream. So it allows you to print out data.

And then there's like a few different options. And then there's print line or print lm, which prints, you know, something like a string that you provide, and then immediately terminate it and put a new nine character in that you don't have to do automatically. There's a regular print, and then there's no, you know, there are a bunch of other as well, you can, you know, feel free to take a look at them. Therefore, different sort of variables. You don't have to, you know, worry about this. If you let's say, do a print, and you pass in an integer.

We haven't covered variables or data types here, but we're going to cover that in a separate video. But if you put a variable that's it, that's all any datatype your handle, it automatically got function overloaded, which again itself enough we're going to cover. So you have the two main print and print ln print ln probably going to do the main one for put quotation marks and I call this print line. And if I run this ad you can see there is a new line. And so we're going to do is just duplicate this on a print line to one free. And if I run it in there all on separate one board I'm going to do is I'm going to set the middle one to just regular print this regular print run app.

As you can see, the first one is on its own line and then at the end, it puts a new line Kota. The next one it printed but it doesn't actually put the new Long character. So the next line starts from the end and not on to the next line. So the new line is actually at the end, not the start of the print line, effective force that newline character by putting backslash n. backslash n is, you know the new law encounters for ronit, we get the same result. So that's it for printing. If you have any questions, feel free to reach out.

There'll be a link with this video to the GitHub page, which will have all the source code from every video in this series. And as usual, thanks for watching. I look forward to seeing you in the next awesome Java video.

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.