Re: Best Java Guides for a Newby?

  • From: "Mike" <foxwarrior09@xxxxxxxxxxx>
  • To: <programmingblind@xxxxxxxxxxxxx>
  • Date: Tue, 2 Aug 2011 02:34:44 -0500

Okay, here is the difference between print() and println(). print() displays text on the screen without ending it with a newline. println() makes a newline after displaying the text. println() is often used so that the output is formatted correctly on the console which is the dos command prompt in Windows 7. print() is used generally when you are getting input from the user, so they can enter the input such as a number on the same line as the prompt. Input would be entered at the end of that line that the prompt is on. To wrap up my explanation on print() and println(), in programming, a line of text is not considered a line until you have the newline character which is like enter in word processing or a regular text editor if that makes sense. The newline signals the end of the line and says, "Okay the next string of text will go to the next line."


To address your issue with the textbook's examples not working with javac, he has a custom made library called TextIO.java to simplify input and output for beginners. Traditionally, in Java, you have to jump through hoops to get input from the keyboard. Please read section 2.6 of the textbook to understand how to address this issue. Read all of it. It will explain how to build TextIO.java with your practice applications, which will allow you to use functions the author wrote for getting input. If you are wondering how his functions work underneath the hood, do not worry; that will be explained briefly in chapter 2 with the section on the Scanner class. I would not recommend using Scanner early on, because TextIO.java has functions that error check the input to keep your programs from crashing. I mean, they error check as in if the user enters the word "hello" when a number is expected, the author's java simplified input/output package will prompt you to reenter the number correctly. I hope all this helps!

Mike
__________
View the list's information and change your settings at //www.freelists.org/list/programmingblind

Other related posts: