<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Java HowTo Guide &#187; Input /Output</title>
	<atom:link href="http://www.javahowtoguide.com/category/java-basics/input-output/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.javahowtoguide.com</link>
	<description>Learn JAVA with US</description>
	<lastBuildDate>Tue, 20 Dec 2011 10:10:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>JAVA &#8211; Console Input</title>
		<link>http://www.javahowtoguide.com/java-console-input/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=java-console-input</link>
		<comments>http://www.javahowtoguide.com/java-console-input/#comments</comments>
		<pubDate>Thu, 08 Jul 2010 13:47:29 +0000</pubDate>
		<dc:creator>Java Tutor</dc:creator>
				<category><![CDATA[Input /Output]]></category>
		<category><![CDATA[Console Input]]></category>

		<guid isPermaLink="false">http://www.javahowtoguide.com/?p=64</guid>
		<description><![CDATA[ <p> </p> <p> </p> <p>Console input refers to keyboard. Most of the times we assign value s to the variables while declaring them. However, there are times when the program depends on the user provided inputs also. For example:</p> <p>String your_name_example;</p> <p>your_name_example  = Console.ReadLine();</p> <p>In this example, first statement declares a string variable ` your_name_example &#8216;. Next statement, the Console.ReadLine command will read the value from console that is value which is entered by the user and store it in the variable ` your_name_example &#8216;.</p> <p>This command works great if you assigning and entering the values into string variables. However, the input that the computer receives from using the command Console.ReadLine(); does not work with data types such as integers or doubles. This command will accept inputs in the text format only. If you try to input other types of variables using Console.ReadLine() command, an error message is generated.</p> <p>Instead you can use the parse command as shown below:</p> <p>int num_var_1;</p> <p>num_var_1 = int.Parse(Console.ReadLine());</p> <p>In the above example, the int.Parse command will convert the text input from the string output of  Console.ReadLine() into an integer variable num_var_1.</p> <p>Similarly, the command double.parse is used to enter a double data type user defined value.</p> <p>Not only this, the command `Console.WriteLine&#8217; can be used to display messages and values stored in variables. For example,</p> <p>Console.WriteLine(&#8220;Hello. This is an example of display message on screen&#8221;);</p> <p></p> <p>The code snippet given below displays the use of the command `Console.WriteLine&#8217; -</p> <p>static void Main(string[] args) { int num_var_1;</p> <p>Console.WriteLine(&#8220;Please enter a number&#8221;); num_var_1=int.Parse(Console.ReadLine()); Console.WriteLine(&#8220;The number you have entered is {0}&#8221;, num_var_1); }</p> <p>In the above code snippet, the first `Console.WriteLine&#8217; command is used to display a simple message: “Please enter a number. “</p> <p>The second `Console.WriteLine&#8217; statement, makes use of a {0} with the message, <p>Continue reading <a href="http://www.javahowtoguide.com/java-console-input/">JAVA &#8211; Console Input</a></p>]]></description>
			<content:encoded><![CDATA[<p><strong><br />
</strong><strong> </strong></p>
<p><strong> </strong></p>
<p>Console input refers to keyboard. Most of the times we assign value s to the variables while declaring them. However, there are times when the program depends on the user provided inputs also. For example:</p>
<p>String your_name_example;</p>
<p>your_name_example  = Console.ReadLine();</p>
<p>In this example, first statement declares a string variable ` your_name_example &#8216;. Next statement, the Console.ReadLine command will read the value from console that is value which is entered by the user and store it in the variable ` your_name_example &#8216;.</p>
<p>This command works great if you assigning and entering the values into string variables. However, the input that the computer receives from using the command Console.ReadLine(); does not work with data types such as integers or doubles. This command will accept inputs in the text format only. If you try to input other types of variables using Console.ReadLine() command, an error message is generated.</p>
<p>Instead you can use the <em>parse</em> command as shown below:</p>
<p>int num_var_1;</p>
<p>num_var_1 = int.Parse(Console.ReadLine());</p>
<p>In the above example, the <em>int.Parse</em> command will convert the text input from the string output of  Console.ReadLine() into an integer variable num_var_1.</p>
<p>Similarly, the command <em>double.parse</em> is used to enter a double data type user defined value.</p>
<p>Not only this, the command `Console.WriteLine&#8217; can be used to display messages and values stored in variables. For example,</p>
<p>Console.WriteLine(&#8220;Hello. This is an example of display message on screen&#8221;);</p>
<p><span id="more-64"></span></p>
<p>The code snippet given below displays the use of the command `Console.WriteLine&#8217; -</p>
<p>static void Main(string[] args) { int num_var_1;</p>
<p>Console.WriteLine(&#8220;Please enter a number&#8221;); num_var_1=int.Parse(Console.ReadLine()); Console.WriteLine(&#8220;The number you have entered is {0}&#8221;, num_var_1); }</p>
<p>In the above code snippet, the first `Console.WriteLine&#8217; command is used to display a simple message: “<strong>Please enter a number</strong>. “</p>
<p>The second `Console.WriteLine&#8217; statement, makes use of a {0} with the message, where 0 acts as a placeholder. When the computer displays the output, it replaces the placeholder with the variable specified after the comma (,), which is num_var_1 in the example</p>
<p>If the user enters the number 56, the message that will be displayed is:</p>
<p><strong>The number you have entered are 56.</strong></p>
<p>Just as a single placeholder is used to input a single variable or value, multiple placeholders can be used to show multiple values or variables. The code snippet given below illustrates the use of this concept:</p>
<p>static void Main(string[] args) {</p>
<p>int num_var_1;</p>
<p>string string_variable_name;</p>
<p>Console.WriteLine(&#8220;Please enter name of your best friend&#8221;);</p>
<p>string_variable_name = Console.ReadLine();</p>
<p>Console.WriteLine(&#8220;Next, please enter age of your best friend&#8221;);</p>
<p>num_var_1=int.Parse(Console.ReadLine());</p>
<p>Console.WriteLine(&#8220;Your best friend {0} is {1} years old&#8221;, string_variable_name, num_var_1);</p>
<p>}</p>
<p>In the example given above, the last `Console.WriteLine&#8217; statement uses two placeholders. When the program is run and the output is displayed, the first placeholder {0} will be replaced by the value stored in the variable ` string_variable_name &#8216;. Similarly, the second placeholder {1} will be replaced by the value stored in variable ` num_var_1&#8242;.</p>
<p>If we input John as name of best friend and 32 as his age, the final output of this program will be – “Your best friend John is 32 years old”.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.javahowtoguide.com/java-console-input/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JAVA &#8211; Console Output Commands</title>
		<link>http://www.javahowtoguide.com/java-console-output-commands/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=java-console-output-commands</link>
		<comments>http://www.javahowtoguide.com/java-console-output-commands/#comments</comments>
		<pubDate>Tue, 11 May 2010 06:27:44 +0000</pubDate>
		<dc:creator>Java Tutor</dc:creator>
				<category><![CDATA[Input /Output]]></category>
		<category><![CDATA[Java Basics]]></category>
		<category><![CDATA[Console Output Commands]]></category>

		<guid isPermaLink="false">http://www.javahowtoguide.com/?p=65</guid>
		<description><![CDATA[<p> </p> <p> </p> <p> </p> <p>Just as the Console Input command, accepts the user defined input, the Console. Output command displays the output on the monitor. In the Java programming language, you can write programs that write text lines to the console, which is a DOS based command window.</p> <p>Though it’s not as popular as a Graphical User Interface or a GUI, the Console.Output command is used sometimes by programmers. Also, the Console.Output command doesn’t work properly with applets, WebStart applications and normal GUI programs. A sample code that shows the dialog or the console output program for simple input/output command is shown below:</p> <p>public class example_Console_Output</p> <p>{</p> <p>public static void main(String[] args) {</p> <p>System.out.println(&#8220;Hello, This is the example of Console Output command. &#8220;);</p> <p>}</p> <p>}</p> <p>The System.out.println command is used to display an entire line of output on the console. The message passed as an argument to the System.out.println command is printed on the console. The println is the short form of print line command and originates from the Pascal programming language.</p> <p></p> <p>You can also substitute the println command with the print command. This command also prints the output to the console. However, it does not start a new line after the output is displayed.</p> <p>Therefore, we can say that println is a method called by the System.out object used for displaying the console output. In this method, as you’ve already seen the data that needs to be displayed is passed as an argument to this command. The command uses a (+) sign to connenct two or more items. Not only this, each time the println command is invoked, it generates a new line once it has finished printing on the console. The example given below displays this:</p> <p>System.out.println(&#8220;The answer to the question is &#8221; + 9390);</p> ]]></description>
			<content:encoded><![CDATA[<p><strong><br />
</strong></p>
<p><strong> </strong></p>
<p><strong> </strong></p>
<p>Just as the Console Input command, accepts the user defined input, the Console. Output command displays the output on the monitor. In the Java programming language, you can write programs that write text lines to the console, which is a DOS based command window.</p>
<p>Though it’s not as popular as a Graphical User Interface or a GUI, the Console.Output command is used sometimes by programmers. Also, the Console.Output command doesn’t work properly with applets, WebStart applications and normal GUI programs. A sample code that shows the dialog or the console output program for simple input/output command is shown below:</p>
<p>public class example_Console_Output</p>
<p>{</p>
<p>public static void main(String[] args) {</p>
<p>System.out.println(&#8220;Hello, This is the example of Console Output command. &#8220;);</p>
<p>}</p>
<p>}</p>
<p>The <strong>System.out.println</strong> command is used to display an entire line of output on the console. The message passed as an argument to the <strong>System.out.println</strong> command is printed on the console. The println is the short form of print line command and originates from the Pascal programming language.</p>
<p><span id="more-65"></span></p>
<p>You can also substitute the println command with the <strong>print </strong>command. This command also prints the output to the console. However, it does not start a new line after the output is displayed.</p>
<p>Therefore, we can say that println is a method called by the System.out object used for displaying the console output. In this method, as you’ve already seen the data that needs to be displayed is passed as an argument to this command. The command uses a (+) sign to connenct two or more items. Not only this, each time the println command is invoked, it generates a new line once it has finished printing on the console. The example given below displays this:</p>
<p>System.out.println(&#8220;The answer to the question is &#8221; + 9390);</p>
]]></content:encoded>
			<wfw:commentRss>http://www.javahowtoguide.com/java-console-output-commands/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

