<?xml version="1.0" encoding="ISO-8859-1"?>

<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
	<channel>
		<title>Java Programming Forum - Learn Java Programming - New To Java</title>
		<link>http://www.java-forums.org/</link>
		<description><![CDATA[New to Java technology and you want to learn Java? Do you have a Java question and don't know which forum is appropriate for it. Then "New to Java" forum is for you.]]></description>
		<language>en</language>
		<lastBuildDate>Tue, 18 Jun 2013 20:19:23 GMT</lastBuildDate>
		<generator>vBulletin</generator>
		<ttl>60</ttl>
		<image>
			<url>http://www.java-forums.org/images/misc/rss.png</url>
			<title>Java Programming Forum - Learn Java Programming - New To Java</title>
			<link>http://www.java-forums.org/</link>
		</image>
		<item>
			<title><![CDATA[Split a string, can't escape '\']]></title>
			<link>http://www.java-forums.org/new-java/78378-split-string-cant-escape.html</link>
			<pubDate>Tue, 18 Jun 2013 18:31:28 GMT</pubDate>
			<description><![CDATA[Basically I'm making a very basic game, playing with java mainly.. I made a save file that the characters name is used in, and the data is stored...]]></description>
			<content:encoded><![CDATA[<div>Basically I'm making a very basic game, playing with java mainly.. I made a save file that the characters name is used in, and the data is stored inside. I got the list of files and converted them to a string with this:<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">&nbsp; &nbsp; &nbsp; &nbsp; File cfile = new File(&quot;lib&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; File filematches&#91;&#93; = cfile.listFiles(new FilenameFilter()<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { public boolean accept(File dir, String name){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return name.endsWith(&quot;.save&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; });<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for(int i = 0; i &lt; filematches.length; i++){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; savefiles&#91;i&#93; = filematches&#91;i&#93;.toString();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</code><hr />
</div>Then I parse through savefiles[], where I want to extract the index 1.<br />
example file name returned: lib\char.save<br />
<br />
I've tried without success to escape the \ so that I can delimit the string at \ and .<br />
Here is what I have been using:<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for(String el : savefiles){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(el != null){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; String delimeter = &quot;&#91;.\\&#93;&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; String&#91;&#93; tokens = el.split(delimeter);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; System.out.println(tokens&#91;0&#93;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</code><hr />
</div>But I get the error: Unexpected internal error near index 2<br />
.\<br />
I looked, and confirmed that \\ should have escaped the special character, but it seems it doesn't. Am I completely missing something? Thanks in advance for any input :)<br />
<br />
/edit: I have tried &quot;.\\&quot; &quot;[.\\]&quot; &quot;[\\.]&quot; &quot;\\.&quot; and still have no idea why it won't work correctly.</div>

]]></content:encoded>
			<category domain="http://www.java-forums.org/new-java/">New To Java</category>
			<dc:creator>skania</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/new-java/78378-split-string-cant-escape.html</guid>
		</item>
		<item>
			<title>Enter a sentence, tells you if each letter is Upper or lower case.</title>
			<link>http://www.java-forums.org/new-java/78358-enter-sentence-tells-you-if-each-letter-upper-lower-case.html</link>
			<pubDate>Tue, 18 Jun 2013 16:08:26 GMT</pubDate>
			<description>Hello all! 
 
I hope you guys can help :)  
 
So this is what I must have... 
 
        Write a program that prompts user to enter a sentence. The...</description>
			<content:encoded><![CDATA[<div>Hello all!<br />
<br />
I hope you guys can help :) <br />
<br />
So this is what I must have...<br />
<br />
        Write a program that prompts user to enter a sentence. The program should display each character on the screen except space character (‘ ‘). For each character, there are three possible outputs to display; &quot;Upper case&quot;, &quot;Lower case&quot;, and &quot;Not a letter&quot;. Note that if the character is a space character, then you do not display space character, and you do not display any of the three possible outputs. Also there must not be a blank line. The program also must show total letter count, total lower case count, and total upper case count. For the total letter count, do not include the space characters, or Non-letter characters. <br />
<br />
You must write two classes; LetterCase and LetterCounter. <br />
<br />
LetterCase class must have the following; <br />
<br />
isThisSpace : Takes a char parameter, returns true if the parameter is a space character. <br />
<br />
isThisUpperCase : Takes a char parameter, returns true if the parameter is upper case. <br />
<br />
isThisLowerCase : Takes a char parameter, returns true if the parameter is lower case. <br />
<br />
main : You must create a LetterCounter object in main method. Read in a sentence from the user. To iterate the characters of the sentence, you must use for loop. In each iteration, call the boolean methods above. Then change the status of the counter if necessary. Then display the letter counts. <br />
<br />
 <br />
LetterCounter class must have the following; <br />
<br />
Default constructor. <br />
<br />
getUpperCount : returns uppercase count (int). Make this method private. <br />
<br />
getLowerCount : returns lowercase count (int). Make this method private. <br />
<br />
increaseUpperCount : increases by one. <br />
<br />
increaseLowerCount : increases by one. <br />
<br />
displayCounts: displays three lines as in the screenshot. Call getUpperCount and getLowerCount methods. <br />
<br />
 <br />
<br />
This is the code I have so far.<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code"> <br />
public class LetterCounter {<br />
int <br />
upper;<br />
int <br />
lower;<br />
public <br />
LetterCounter()<br />
{<br />
<br />
}<br />
<br />
private <br />
int getUpperCount(){<br />
return <br />
upper;}<br />
<br />
private <br />
int getLowerCount(){<br />
return <br />
lower;}<br />
<br />
public <br />
void <br />
increaseUpperCount(int amount){<br />
upper=upper+amount;<br />
}<br />
public <br />
void increasLowerCount(int amount){<br />
lower=lower+amount;<br />
}<br />
<br />
public <br />
int displayCounts(){<br />
System.out.print(&quot;Letter Count: &quot;);<br />
System.out.println(&quot;Lower Count: &quot;);<br />
return <br />
getLowerCount();<br />
System.out.println(&quot;Upper Count: &quot;);<br />
return <br />
getUpperCount();<br />
<br />
}<br />
<br />
&#12288;<br />
}</code><hr />
</div><div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">import java.util.Scanner;<br />
<br />
public class LetterCase <br />
{<br />
char ch;<br />
static String sentence;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; public static void main(String&#91;&#93; args) <br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; System.out.print(&quot;Please enter a sentence: &quot;); <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Scanner keyboard = new Scanner(System.in); <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; String sentence = keyboard.next();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; LetterCounter ch=&nbsp; LetterCounter;&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public static boolean isThisSpace(char input)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return true;&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public void isThisUpperCase(char ch)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (!(Character.isLowerCase(ch)))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (int i=1; i&lt;sentence.length(); i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  ch = sentence.charAt(i);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (!Character.isUpperCase(ch))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  {&nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  sentence = &quot;&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
<br />
<br />
} System.out.print(sentence);}}</code><hr />
</div>Questions I have: I'm lost!  Can you please push me in the right direction?<br />
<br />
<br />
<br />
Oh ya, and attached is the sample output.</div>


	<div style="padding:10px">

	

	

	
		<fieldset class="fieldset">
			<legend>Attached Images</legend>
			<ul>
			<li>
	<img class="inlineimg" src="http://www.java-forums.org/images/attach/png.gif" alt="File Type: png" />
	<a href="http://www.java-forums.org/attachments/new-java/5161d1371571402-enter-sentence-tells-you-if-each-letter-upper-lower-case-image-3.png" target="_blank">Image 3.png</a> 
(170.2 KB)
</li>
			</ul>
			</fieldset>
	

	

	</div>
]]></content:encoded>
			<category domain="http://www.java-forums.org/new-java/">New To Java</category>
			<dc:creator>pence</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/new-java/78358-enter-sentence-tells-you-if-each-letter-upper-lower-case.html</guid>
		</item>
		<item>
			<title>Listeners help!!</title>
			<link>http://www.java-forums.org/new-java/78357-listeners-help.html</link>
			<pubDate>Tue, 18 Jun 2013 15:32:07 GMT</pubDate>
			<description>im building a calculator and i want to press the button, get the text and set it in the text field as a text....but i want to touch any button not...</description>
			<content:encoded><![CDATA[<div>im building a calculator and i want to press the button, get the text and set it in the text field as a text....but i want to touch any button not one in expecific</div>

]]></content:encoded>
			<category domain="http://www.java-forums.org/new-java/">New To Java</category>
			<dc:creator>Luwine</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/new-java/78357-listeners-help.html</guid>
		</item>
		<item>
			<title>Problem with System.nanoTime()</title>
			<link>http://www.java-forums.org/new-java/78356-problem-system-nanotime.html</link>
			<pubDate>Tue, 18 Jun 2013 15:20:27 GMT</pubDate>
			<description>Hello i am following a tutorial and im making a timer following this. However i seem to have a problem with System.nanoTime. It seems that it only...</description>
			<content:encoded><![CDATA[<div>Hello i am following a tutorial and im making a timer following this. However i seem to have a problem with System.nanoTime. It seems that it only updates its value every microsecond instead of nanosecond. Whenever i call the System.nanoTime() function i get a value that ends with 3 zeros. <br />
<br />
For example: <br />
&quot;1371568052578915000, 1371568052578916000&quot;. <br />
<br />
This is what i get everytime. I have not done anything to the variable that stores it before i print it out, and printing out System.nanoTime() directly does not change the problem.<br />
<br />
Here is the code part of the code that i am having problems with. It is not complete yet but i can not imagine anyway that could be relevant to my problem. The &quot;return;&quot; is just temporary.<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">long lastTime = System.nanoTime();<br />
final double ns = 1000000000.0 / 60.0;<br />
double delta = 0.0;<br />
while(running){<br />
&nbsp; &nbsp; &nbsp; &nbsp; long now = System.nanoTime();<br />
&nbsp; &nbsp; &nbsp; &nbsp; System.out.printf(lastTime + &quot;, &quot; + now);<br />
&nbsp; &nbsp; &nbsp; &nbsp; return;<br />
&nbsp; &nbsp; &nbsp; &nbsp; //tick();<br />
&nbsp; &nbsp; &nbsp; &nbsp; //render();<br />
}</code><hr />
</div></div>

]]></content:encoded>
			<category domain="http://www.java-forums.org/new-java/">New To Java</category>
			<dc:creator>karl_marx</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/new-java/78356-problem-system-nanotime.html</guid>
		</item>
		<item>
			<title>while loop not checking if it can loop</title>
			<link>http://www.java-forums.org/new-java/78342-while-loop-not-checking-if-can-loop.html</link>
			<pubDate>Tue, 18 Jun 2013 12:20:06 GMT</pubDate>
			<description><![CDATA[I'm working on a project and realized something weird. My while loop isn't checking if it can loop. 
 
Here is a little example code: 
<div...]]></description>
			<content:encoded><![CDATA[<div>I'm working on a project and realized something weird. My while loop isn't checking if it can loop.<br />
<br />
Here is a little example code:<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code"><br />
public class WhileLoop {<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; boolean running = false;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int i;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; public WhileLoop() {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; running = true;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  runThread();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; while (running) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; i++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; System.out.println(&quot;test&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; public static void main(String args&#91;&#93;) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; new WhileLoop();<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; public void runThread() {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; new Thread() {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public void run() {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; while (true) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; try {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sleep(1000);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } catch (InterruptedException e) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; e.printStackTrace();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; System.out.println(i);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; running = false;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }.start();<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
}</code><hr />
</div>Yes, I typed while(true), you mad?<br />
<br />
As you might see I started the thread inside runThread() and when one second has gone it prints the value of i (to see if it changes and it does) and sets running to false<br />
in my &quot;main&quot; while loop is checks if running = true and if it is keep looping. but when the thread changes running to false it doesn't get out of the loop. But if I make the loop print something (even System.out.println();) it checks if the statement is true and if it isn't it gets out if the loop. <br />
<br />
So my question: Why isn't the loop checking if the statement is true or not if I don't print something?<br />
<br />
Thanks for answers!</div>

]]></content:encoded>
			<category domain="http://www.java-forums.org/new-java/">New To Java</category>
			<dc:creator>totalspelnerd</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/new-java/78342-while-loop-not-checking-if-can-loop.html</guid>
		</item>
		<item>
			<title>While loop/if statement problem</title>
			<link>http://www.java-forums.org/new-java/78341-while-loop-if-statement-problem.html</link>
			<pubDate>Tue, 18 Jun 2013 10:36:38 GMT</pubDate>
			<description><![CDATA[Sorry for my awful title. I can't even explain my problem I'm having without is being to long. 
 
I was working on a project today and the while...]]></description>
			<content:encoded><![CDATA[<div>Sorry for my awful title. I can't even explain my problem I'm having without is being to long.<br />
<br />
I was working on a project today and the while loop/if statement is acting really weird.<br />
<br />
Here is my SSCCE code (I know &quot;while(true)&quot; don't comment on it):<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">public class WhileLoop {<br />
&nbsp; &nbsp; &nbsp; &nbsp; public WhileLoop(){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int i = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; while(true){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; i++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(i==-1){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; System.out.println(&quot;Test&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; public static void main(String args&#91;&#93;){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; new WhileLoop();<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
}</code><hr />
</div>when I run this it keeps printing Test all the time. So my question is how can the variable be equal to -1 when I add one to it all the time?</div>

]]></content:encoded>
			<category domain="http://www.java-forums.org/new-java/">New To Java</category>
			<dc:creator>totalspelnerd</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/new-java/78341-while-loop-if-statement-problem.html</guid>
		</item>
		<item>
			<title>JMF: problem with YUV format</title>
			<link>http://www.java-forums.org/new-java/78333-jmf-problem-yuv-format.html</link>
			<pubDate>Tue, 18 Jun 2013 08:03:31 GMT</pubDate>
			<description><![CDATA[hi., 
plz help me...i'm working with JMStudio since two weeks...i have 32 bit java rutime environment n have installed JMF1.1.2e....Im gettng the...]]></description>
			<content:encoded><![CDATA[<div>hi.,<br />
plz help me...i'm working with JMStudio since two weeks...i have 32 bit java rutime environment n have installed JMF1.1.2e....Im gettng the same error as mentioned above while working with capturing video with inbuilt webcam in ma PC with windows7 OS</div>

]]></content:encoded>
			<category domain="http://www.java-forums.org/new-java/">New To Java</category>
			<dc:creator>Bhumi</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/new-java/78333-jmf-problem-yuv-format.html</guid>
		</item>
		<item>
			<title>Aggregating class</title>
			<link>http://www.java-forums.org/new-java/78273-aggregating-class.html</link>
			<pubDate>Tue, 18 Jun 2013 00:49:28 GMT</pubDate>
			<description><![CDATA[3. Create an aggregating class 
 
   Write a class called "Line".  It should store two Point objects.  It should have two 
   constructors, one that...]]></description>
			<content:encoded><![CDATA[<div>3. Create an aggregating class<br />
<br />
   Write a class called &quot;Line&quot;.  It should store two Point objects.  It should have two<br />
   constructors, one that receives 4 ints to set the (x,y) of each end, and the other<br />
   that receives two Point objects.<br />
<br />
   It should have a distance method that computes the length of the line.  Its toString<br />
   method should print like this:  (x,y) to (x,y)<br />
<br />
   Write a main method that creates a line with each constructor.  It should then print <br />
   each line and its length.<br />
<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">import java.awt.Point;<br />
<br />
public class Line <br />
{<br />
&nbsp; &nbsp; private Point p1, p2;<br />
&nbsp; &nbsp; private int x1, x2, y1, y2;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; public Line(int x1, int x2, int y1, int y2)<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; this.x1 = x1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; this.y1 = y1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; this.x2 = x2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; this.y2 = y2;<br />
&nbsp; &nbsp; }<br />
&nbsp; &nbsp; public Line(Point p1, Point p2)<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; this.p1 = p1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; this.p2 = p2;<br />
&nbsp; &nbsp; }<br />
&nbsp; &nbsp; public double Distance(int x1, int y1, int x2, int y2)<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; return Math.sqrt( (x2-x1)*(x2-x1) + (y2-y1)*(y2-y1) );<br />
&nbsp; &nbsp; }<br />
&nbsp; &nbsp; public String toString()<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; String str = &quot;(&quot; + x1 + &quot;,&quot; + y1 + &quot;)&quot; + &quot; to &quot; + &quot;(&quot; + x2 + &quot;,&quot; + y2 + &quot;)&quot; + <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot; has a length of &quot; + Distance(x1,y1,x2,y2);<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; return str;<br />
&nbsp; &nbsp; }<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; public static void main(String&#91;&#93; args) <br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; Line line = new Line(2,4,6,5);<br />
&nbsp; &nbsp; &nbsp; &nbsp; Point point = new Point(4,3);<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; System.out.println(line.toString());<br />
&nbsp; &nbsp; &nbsp; &nbsp; System.out.println(point.toString());<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; }<br />
&nbsp; &nbsp; <br />
}</code><hr />
</div>Output:<br />
<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">(2,6) to (4,5) has a length of 2.23606797749979<br />
java.awt.Point&#91;x=4,y=3&#93;</code><hr />
</div>The Point objects constructor is throwing me off. I am not sure where to go from here.<br />
<br />
Any help is appreciated.</div>

]]></content:encoded>
			<category domain="http://www.java-forums.org/new-java/">New To Java</category>
			<dc:creator>Bcode</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/new-java/78273-aggregating-class.html</guid>
		</item>
		<item>
			<title>Need Help!</title>
			<link>http://www.java-forums.org/new-java/78261-need-help.html</link>
			<pubDate>Mon, 17 Jun 2013 22:34:45 GMT</pubDate>
			<description>Can someone tell me whats wrong here please. 
 
Attachment 5160 (http://www.java-forums.org/attachments/new-java/5160-need-help-java_problem.jpg)</description>
			<content:encoded><![CDATA[<div>Can someone tell me whats wrong here please.<br />
<br />
<a href="http://www.java-forums.org/attachments/new-java/5160d1371508429-need-help-java_problem.jpg"  title="Name:  Java_Problem.JPG
Views: 9
Size:  39.5 KB">Java_Problem.JPG</a></div>


	<div style="padding:10px">

	

	

	
		<fieldset class="fieldset">
			<legend>Attached Images</legend>
			<ul>
			<li>
	<img class="inlineimg" src="http://www.java-forums.org/images/attach/jpg.gif" alt="File Type: jpg" />
	<a href="http://www.java-forums.org/attachments/new-java/5160d1371508429-need-help-java_problem.jpg" target="_blank">Java_Problem.JPG</a> 
(39.5 KB)
</li>
			</ul>
			</fieldset>
	

	

	</div>
]]></content:encoded>
			<category domain="http://www.java-forums.org/new-java/">New To Java</category>
			<dc:creator>zacM16</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/new-java/78261-need-help.html</guid>
		</item>
		<item>
			<title>output error</title>
			<link>http://www.java-forums.org/new-java/78223-output-error.html</link>
			<pubDate>Mon, 17 Jun 2013 17:35:04 GMT</pubDate>
			<description>No output :( 
 
i am trying to get the program to out put the translated to morsecode text.  it should reade from the file and translate to morse and...</description>
			<content:encoded><![CDATA[<div>No output :(<br />
<br />
i am trying to get the program to out put the translated to morsecode text.  it should reade from the file and translate to morse and output the code...<br />
<br />
<br />
<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code"> <br />
import javax.swing.JOptionPane;<br />
import java.io.*;<br />
public class Morse<br />
{<br />
&nbsp; &nbsp; public static void main(String&#91;&#93; args)throws IOException<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; String userInput;<br />
&nbsp; &nbsp; &nbsp; &nbsp; final String SENTINEL = &quot;0&quot;;//for exiting program when entered<br />
&nbsp; &nbsp; &nbsp; &nbsp; //object creation<br />
&nbsp; &nbsp; &nbsp; &nbsp; Translate text = new Translate();<br />
&nbsp; &nbsp; &nbsp; &nbsp; //getting user input to be translated<br />
&nbsp; &nbsp; &nbsp; &nbsp; do<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; userInput = JOptionPane.showInputDialog(&quot;Please enter what you wish to translte to Morse code (no punctuation).&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; String compare = userInput.toUpperCase();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; String&#91;&#93; codedText = new String&#91;compare.length()&#93;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; codedText = text.translateHere(compare);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; text.toString(userInput, codedText);<br />
&nbsp; &nbsp; &nbsp; &nbsp; }while(!userInput.equals(SENTINEL));<br />
&nbsp; &nbsp; }//end main<br />
}//end class</code><hr />
</div><div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">import java.io.File;<br />
import java.io.IOException;<br />
import java.util.Scanner;<br />
<br />
public class Translate {<br />
&nbsp;public Translate()<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; }//end default constructor<br />
&nbsp; &nbsp; public String&#91;&#93; translateHere(String s)throws IOException<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; String compare = s, codedLine = &quot;&quot;;&nbsp; //userInput toUpperCase<br />
&nbsp; &nbsp; &nbsp; &nbsp; int length = compare.length();&nbsp; //length of userInput<br />
&nbsp; &nbsp; &nbsp; &nbsp; String line, file = &quot;Morse.txt&quot;;// variable holding file name and variable for each letter/number<br />
&nbsp; &nbsp; &nbsp; &nbsp; char code;<br />
&nbsp; &nbsp; &nbsp; &nbsp; //Constants<br />
&nbsp; &nbsp; &nbsp; &nbsp; final int MAX = 36;<br />
&nbsp; &nbsp; &nbsp; &nbsp; //Arrays<br />
&nbsp; &nbsp; &nbsp; &nbsp; char&#91;&#93; morseLetter = new char&#91;MAX&#93;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; String&#91;&#93; morseCode = new String&#91;MAX&#93;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; String&#91;&#93; newMessage = new String&#91;length&#93;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; //putting user input in a character array;<br />
&nbsp; &nbsp; &nbsp; &nbsp; char&#91;&#93; userLetters = compare.toCharArray();<br />
&nbsp; &nbsp; &nbsp; &nbsp; //object creation<br />
&nbsp; &nbsp; &nbsp; &nbsp; File openFile = new File(file);<br />
&nbsp; &nbsp; &nbsp; &nbsp; Scanner inFile = new Scanner(openFile);<br />
&nbsp; &nbsp; &nbsp; &nbsp; int&nbsp; counter = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; while(inFile.hasNext())<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; line = inFile.next();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; code = (char)line.charAt(0);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //System.out.println(code);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; morseLetter&#91;counter&#93; = code;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; morseCode&#91;counter&#93; = inFile.next();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; counter++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }//end nested while loop<br />
&nbsp; &nbsp; &nbsp; &nbsp; for(int j = 0; j &lt; length; j++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for(int k = 0; k &lt; MAX; k++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(userLetters&#91;j&#93; == morseLetter&#91;k&#93;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; newMessage&#91;j&#93; = morseCode&#91;k&#93;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }//end nested for loop<br />
&nbsp; &nbsp; &nbsp; &nbsp; }//end for loop<br />
&nbsp; &nbsp; &nbsp; &nbsp; return newMessage;<br />
&nbsp; &nbsp; }//end method that completes translateion<br />
&nbsp; &nbsp; public String toString(String a, String&#91;&#93; b)<br />
{<br />
&nbsp;  System.out.println(&quot;Input: &quot; + a);<br />
&nbsp;  System.out.println(&quot;Output:&quot;);<br />
&nbsp;  String output = &quot;&quot;;<br />
&nbsp;  for(int i = 0; i &lt; b.length; i++)<br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; output = output + b&#91;i&#93;;<br />
&nbsp;  }<br />
&nbsp;  return output;<br />
&nbsp;}//end toString method<br />
}//end Translate Class</code><hr />
</div></div>

]]></content:encoded>
			<category domain="http://www.java-forums.org/new-java/">New To Java</category>
			<dc:creator>mentoes178</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/new-java/78223-output-error.html</guid>
		</item>
		<item>
			<title>Java Program Morse Code Translator</title>
			<link>http://www.java-forums.org/new-java/78221-java-program-morse-code-translator.html</link>
			<pubDate>Mon, 17 Jun 2013 17:03:09 GMT</pubDate>
			<description><![CDATA[I have written this program but unfortunately there is not output... i don't know what I am doing wrong.... 
 
this is for the main: 
 
<div...]]></description>
			<content:encoded><![CDATA[<div>I have written this program but unfortunately there is not output... i don't know what I am doing wrong....<br />
<br />
this is for the main:<br />
<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code"> <br />
import javax.swing.JOptionPane;<br />
import java.io.*;<br />
public class Morse<br />
{<br />
&nbsp; &nbsp; public static void main(String&#91;&#93; args)throws IOException<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; String userInput;<br />
&nbsp; &nbsp; &nbsp; &nbsp; final String SENTINEL = &quot;0&quot;;//for exiting program when entered<br />
&nbsp; &nbsp; &nbsp; &nbsp; //object creation<br />
&nbsp; &nbsp; &nbsp; &nbsp; Translate text = new Translate();<br />
&nbsp; &nbsp; &nbsp; &nbsp; //getting user input to be translated<br />
&nbsp; &nbsp; &nbsp; &nbsp; do<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; userInput = JOptionPane.showInputDialog(&quot;Please enter what you wish to translte to Morse code (no punctuation).&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; String compare = userInput.toUpperCase();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; String&#91;&#93; codedText = new String&#91;compare.length()&#93;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; codedText = text.translateHere(compare);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; text.toString(userInput, codedText);<br />
&nbsp; &nbsp; &nbsp; &nbsp; }while(!userInput.equals(SENTINEL));<br />
&nbsp; &nbsp; }//end main<br />
}//end class</code><hr />
</div>and this for the class:<br />
<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">import java.io.File;<br />
import java.io.IOException;<br />
import java.util.Scanner;<br />
<br />
public class Translate {<br />
&nbsp;public Translate()<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; }//end default constructor<br />
&nbsp; &nbsp; public String&#91;&#93; translateHere(String s)throws IOException<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; String compare = s, codedLine = &quot;&quot;;&nbsp; //userInput toUpperCase<br />
&nbsp; &nbsp; &nbsp; &nbsp; int length = compare.length();&nbsp; //length of userInput<br />
&nbsp; &nbsp; &nbsp; &nbsp; String line, file = &quot;Morse.txt&quot;;// variable holding file name and variable for each letter/number<br />
&nbsp; &nbsp; &nbsp; &nbsp; char code;<br />
&nbsp; &nbsp; &nbsp; &nbsp; //Constants<br />
&nbsp; &nbsp; &nbsp; &nbsp; final int MAX = 36;<br />
&nbsp; &nbsp; &nbsp; &nbsp; //Arrays<br />
&nbsp; &nbsp; &nbsp; &nbsp; char&#91;&#93; morseLetter = new char&#91;MAX&#93;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; String&#91;&#93; morseCode = new String&#91;MAX&#93;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; String&#91;&#93; newMessage = new String&#91;length&#93;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; //putting user input in a character array;<br />
&nbsp; &nbsp; &nbsp; &nbsp; char&#91;&#93; userLetters = compare.toCharArray();<br />
&nbsp; &nbsp; &nbsp; &nbsp; //object creation<br />
&nbsp; &nbsp; &nbsp; &nbsp; File openFile = new File(file);<br />
&nbsp; &nbsp; &nbsp; &nbsp; Scanner inFile = new Scanner(openFile);<br />
&nbsp; &nbsp; &nbsp; &nbsp; int&nbsp; counter = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; while(inFile.hasNext())<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; line = inFile.next();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; code = (char)line.charAt(0);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //System.out.println(code);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; morseLetter&#91;counter&#93; = code;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; morseCode&#91;counter&#93; = inFile.next();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; counter++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }//end nested while loop<br />
&nbsp; &nbsp; &nbsp; &nbsp; for(int j = 0; j &lt; length; j++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for(int k = 0; k &lt; MAX; k++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(userLetters&#91;j&#93; == morseLetter&#91;k&#93;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; newMessage&#91;j&#93; = morseCode&#91;k&#93;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }//end nested for loop<br />
&nbsp; &nbsp; &nbsp; &nbsp; }//end for loop<br />
&nbsp; &nbsp; &nbsp; &nbsp; return newMessage;<br />
&nbsp; &nbsp; }//end method that completes translateion<br />
&nbsp; &nbsp; public String toString(String a, String&#91;&#93; b)<br />
{<br />
&nbsp;  System.out.println(&quot;Input: &quot; + a);<br />
&nbsp;  System.out.println(&quot;Output:&quot; + );<br />
&nbsp;  String output = &quot;&quot;;<br />
&nbsp;  for(int i = 0; i &lt; b.length; i++)<br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; output = output + b&#91;i&#93;;<br />
&nbsp;  }<br />
&nbsp;  return output;<br />
&nbsp;}//end toString method<br />
}//end Translate Class</code><hr />
</div></div>

]]></content:encoded>
			<category domain="http://www.java-forums.org/new-java/">New To Java</category>
			<dc:creator>mentoes178</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/new-java/78221-java-program-morse-code-translator.html</guid>
		</item>
		<item>
			<title>Using Date() to get Start Time and Finish Time</title>
			<link>http://www.java-forums.org/new-java/78217-using-date-get-start-time-finish-time.html</link>
			<pubDate>Mon, 17 Jun 2013 16:46:17 GMT</pubDate>
			<description>I have a single file copy that I want to record the start time and the finish time for. The code below indeed provide me with time, but the start and...</description>
			<content:encoded><![CDATA[<div>I have a single file copy that I want to record the start time and the finish time for. The code below indeed provide me with time, but the start and finish are the same. I know for a fact that it takes about 34 seconds for this particular file to copy from the source path to the destination path. I timed it with a stopwatch. If anything, my seconds under the start time should be different that the seconds for the finish time. Could another set of eyes tell what I am doing wrong?<br />
<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; // Copy File and capture the start time and finish time then display<br />
&nbsp; &nbsp; &nbsp; &nbsp; String url1 = jTextField3.getText();<br />
&nbsp; &nbsp; &nbsp; &nbsp; String url2 = jTextField1.getText();<br />
&nbsp; &nbsp; &nbsp; &nbsp; Date dNow = new Date();<br />
&nbsp; &nbsp; &nbsp; &nbsp; SimpleDateFormat ft = new SimpleDateFormat(&quot;M/dd/yy&nbsp;  hh:mm:ss a&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; Path path1 = Paths.get(url1);<br />
&nbsp; &nbsp; &nbsp; &nbsp; Path path2 = Paths.get(url2);<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; jLabel2.setText(ft.format(dNow)); //setting start time as label text<br />
&nbsp; &nbsp; &nbsp; &nbsp; try<br />
&nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Files.copy(path1, path2);&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; catch(IOException e)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; JOptionPane.showMessageDialog(null, &quot;There was a problem&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; e.printStackTrace();<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; jLabel3.setText(ft.format(dNow)); //setting finish time as label text&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; }</code><hr />
</div></div>

]]></content:encoded>
			<category domain="http://www.java-forums.org/new-java/">New To Java</category>
			<dc:creator>dalythe</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/new-java/78217-using-date-get-start-time-finish-time.html</guid>
		</item>
		<item>
			<title>Java Program Morse Code Translator</title>
			<link>http://www.java-forums.org/new-java/78209-java-program-morse-code-translator.html</link>
			<pubDate>Mon, 17 Jun 2013 16:09:48 GMT</pubDate>
			<description>A Java program is to be created to produce Morse code. The Morse code assigns a  
series of dots and dashes to each letter of the alphabet, each...</description>
			<content:encoded><![CDATA[<div>A Java program is to be created to produce Morse code. The Morse code assigns a <br />
series of dots and dashes to each letter of the alphabet, each digit, and a few special characters (such as <br />
period, comma, colon, and semicolon). In sound-oriented systems, the dot represents a short sound and the <br />
dash represents a long sound. Separation between words is indicated by a space, or, quite simply, the <br />
absence of a dot or dash. In a sound-oriented system, a space is indicated by a short period of time during <br />
which no sound is transmitted. The international version of the Morse code is stored in the data file Morse.txt. <br />
To process the program, the Morse code data file (Morse.txt) should be read and stored in memory for fast <br />
access to the code. Each letter of the alphabet has a Morse code equivalent. After the code table is stored, the <br />
user should be prompted for an English language sentence to be entered from the keyboard. This sentence<br />
should be encoded into Morse and displayed. One blank should be used to separate each Morse-coded letter <br />
and three blanks should be used to separate each Morse-coded word. The user should be allowed to continue <br />
with the process of entering a sentence and having it encoded until a sentinel value (0) is received.<br />
Input: The letters and their equivalents are stored in a data file named Morse.txt. Input will consist of the <br />
Morse.txt file and well as the sentences entered from the keyboard. The data file should be read and loaded <br />
into memory at the beginning of the program before the sentences can be read and encoded. Each line of the <br />
data file contains the letter of the alphabet followed by the code equivalent. The data file should be read and <br />
stored in an array for fast and easy access during the program duration. When a sentence is read from the <br />
keyboard, it can be translated from the data stored from the Morse code file.<br />
<br />
Create a driver (main) class named Morse.java. <br />
&#61607; Create a utility class named Translate.java which translates the sentences inputted from the user into <br />
Morse code.<br />
&#61607; You may design your utility class where you pass the entire sentence into its constructor or pass one <br />
character at a time. You may elect to do output from either the driver or utility class.<br />
&#61607; Include comments defining the purpose of the code. <br />
&#61607; Include a comment stating your name.<br />
&#61607; Use all Java conventions such as naming conventions and indentation.</div>

]]></content:encoded>
			<category domain="http://www.java-forums.org/new-java/">New To Java</category>
			<dc:creator>mentoes178</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/new-java/78209-java-program-morse-code-translator.html</guid>
		</item>
		<item>
			<title>Java url downloader</title>
			<link>http://www.java-forums.org/new-java/78208-java-url-downloader.html</link>
			<pubDate>Mon, 17 Jun 2013 16:08:46 GMT</pubDate>
			<description>Im working on a program that i can get to do WAY more than just url downloading. Im trying to get to download a url, Got that to work. But now i want...</description>
			<content:encoded><![CDATA[<div>Im working on a program that i can get to do WAY more than just url downloading. Im trying to get to download a url, Got that to work. But now i want the user to be able to type <br />
 in the console &quot;<br />
 This is a multiple class program. There is 3 files for now.<br />
<br />
 A.java the main class<br />
 <div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code"> package main;<br />
&nbsp;public class A {<br />
&nbsp;public static void main(String args&#91;&#93;) throws Exception{<br />
&nbsp;aa aamain = new aa();<br />
&nbsp;ab abmain = new ab();<br />
&nbsp;abmain.ask1();<br />
<br />
<br />
&nbsp;}<br />
<br />
&nbsp;}</code><hr />
</div> aa.java the downloader<br />
 <div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code"> package main;<br />
&nbsp;import java.util.Scanner; <br />
&nbsp;import java.net.*;<br />
&nbsp;import java.io.*;<br />
&nbsp;import java.io.BufferedWriter;<br />
&nbsp;import java.io.File;<br />
&nbsp;import java.io.FileOutputStream;<br />
&nbsp;import java.io.IOException;<br />
&nbsp;import java.io.OutputStreamWriter;<br />
&nbsp;import java.io.Writer;<br />
&nbsp;public class aa {<br />
&nbsp;private static Scanner user_input2;<br />
&nbsp;public static void callUrl() throws Exception {<br />
&nbsp;aa aamain = new aa();<br />
&nbsp;System.out.println(&quot;Called URL CALLER please enter the url IE: http://google.com or:http://facebook.com/index.html&quot;);<br />
&nbsp;user_input2 = new Scanner( System.in );<br />
&nbsp;String urlname;<br />
&nbsp;urlname = user_input2.next( );<br />
&nbsp;URL yahoo = new URL(&quot;http://&quot; + urlname);<br />
&nbsp;URLConnection yc = yahoo.openConnection();<br />
&nbsp;BufferedReader in = new BufferedReader(<br />
&nbsp;new InputStreamReader(<br />
&nbsp;yc.getInputStream()));<br />
&nbsp;String inputLine;<br />
&nbsp;while ((inputLine = in.readLine()) != null)<br />
&nbsp;try {<br />
&nbsp;//What ever the file path is.<br />
&nbsp;File statText = new File(urlname + &quot;.file&quot;);<br />
&nbsp;FileOutputStream is = new FileOutputStream(statText);<br />
&nbsp;OutputStreamWriter osw = new OutputStreamWriter(is); <br />
&nbsp;Writer w = new BufferedWriter(osw);<br />
&nbsp;w.write(inputLine);<br />
&nbsp;w.close();<br />
&nbsp;} catch (IOException e) {<br />
&nbsp;System.err.println(&quot;File FAILED!&quot;);<br />
&nbsp;}<br />
&nbsp;System.out.println(inputLine);<br />
&nbsp;in.close();<br />
&nbsp;}<br />
&nbsp;}<br />
<br />
&nbsp;//the class &quot;aa.java&quot; is what i updated please help me fix it only writing on one line. i want it to write the whole file on it.</code><hr />
</div> ab.java the console class<br />
 <div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code"> package main;<br />
&nbsp;import java.util.Scanner;<br />
&nbsp;public class ab {<br />
&nbsp;private static Scanner user_input;<br />
<br />
&nbsp;public static void ask1() throws Exception{<br />
&nbsp;aa aamain = new aa();<br />
&nbsp;System.out.println(&quot;Main console.&quot;);<br />
&nbsp;user_input = new Scanner( System.in );<br />
&nbsp;String first_name;<br />
&nbsp;first_name = user_input.next( );<br />
&nbsp;System.out.println(first_name);<br />
<br />
<br />
&nbsp;if(first_name.equals(&quot;callurl&quot;)){<br />
<br />
&nbsp;aamain.callUrl();<br />
<br />
&nbsp;}<br />
&nbsp;}<br />
&nbsp;}</code><hr />
</div> What i want to be able to do is have the user type &quot;callurl&quot; then without hitting enter, &quot;http://google.com&quot; or other websites. but i can only get it to download what i put in the one line of aa.java <br />
 on line:<br />
 <div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code"> URL yahoo = new URL(&quot;http://www.yahoo.com/&quot;);</code><hr />
</div> NVM i got the way to get the users input on the url thay want. Now i need a way to write what it gets to a file.... in the same folder that the program is in.<br />
 instead of putting it in the console.<br />
 Any ideas?</div>

]]></content:encoded>
			<category domain="http://www.java-forums.org/new-java/">New To Java</category>
			<dc:creator>tnd_blazer</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/new-java/78208-java-url-downloader.html</guid>
		</item>
		<item>
			<title><![CDATA[Can an extended class "know" if a certain function from the base class is overridden?]]></title>
			<link>http://www.java-forums.org/new-java/78174-can-extended-class-know-if-certain-function-base-class-overridden.html</link>
			<pubDate>Mon, 17 Jun 2013 14:54:02 GMT</pubDate>
			<description><![CDATA[I have a base class with a dummy function call to allow editing of class fields. 
 
Let's call the method editClassFields(). 
 
In practice, all...]]></description>
			<content:encoded><![CDATA[<div>I have a base class with a dummy function call to allow editing of class fields.<br />
<br />
Let's call the method editClassFields().<br />
<br />
In practice, all objects extend the class to add extra fields, methods, etc. but not all of them have a need to call editClassFields().  In those cases I don't override the base editClassFields() method.<br />
<br />
What I'm looking for is a way for the extended classes to &quot;know&quot; whether or not the editClassFields() has been overridden, so that they can display themselves slightly differently.  This lets the user know (by a subtle change in appearance) that they can edit the fields.<br />
<br />
Coming from the world of C/C++, I still have this concept in my mind of &quot;function pointers&quot; and so thinking along those lines I could compare<br />
<br />
this.editClassFields() to super.editClassFields().  And if they were the same, then the base method would not have been overridden.<br />
<br />
What's a good way to do this in Java without requiring me to add another field indicating whether or not the base method has been overridden?<br />
<br />
Thanks,<br />
<br />
DL</div>

]]></content:encoded>
			<category domain="http://www.java-forums.org/new-java/">New To Java</category>
			<dc:creator>Digital Larry</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/new-java/78174-can-extended-class-know-if-certain-function-base-class-overridden.html</guid>
		</item>
		<item>
			<title>Error during compilation.</title>
			<link>http://www.java-forums.org/new-java/78173-error-during-compilation.html</link>
			<pubDate>Mon, 17 Jun 2013 14:47:19 GMT</pubDate>
			<description>import java.util.*; 
                    class x 
l                  { 
                  int a,b; 
                      void function(int m,int n)...</description>
			<content:encoded><![CDATA[<div>import java.util.*;<br />
                    class x<br />
l                  {<br />
                  int a,b;<br />
                      void function(int m,int n)<br />
                    {<br />
                       a=m;b=n;<br />
                      }<br />
                       int sum()<br />
                     {<br />
                       int c;<br />
                       c=a+b;<br />
                      return(c);<br />
                      }<br />
                      public static void main()<br />
                     {<br />
                      Scanner obj1=new Scanner(System.in);<br />
                      x obj2=new x();<br />
                      int p,q,s;<br />
                        System.out.println(&quot;Enter the no.&quot;);<br />
                     p=obj1.nextInt();<br />
                    q=obj1.nextInt();<br />
                    <font color="#FFFF00">obj1.input(p,q);</font><br />
                   s=obj2.sum();<br />
                     System.out.println(&quot;sum=&quot;+s);<br />
                      }<br />
                     }<br />
<br />
<br />
<br />
<br />
I get an error in line 23 which says cannot find symbol-method input(int,int) in line</div>

]]></content:encoded>
			<category domain="http://www.java-forums.org/new-java/">New To Java</category>
			<dc:creator>mohammad.stuggart</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/new-java/78173-error-during-compilation.html</guid>
		</item>
		<item>
			<title>Flat File Database for Java</title>
			<link>http://www.java-forums.org/new-java/78172-flat-file-database-java.html</link>
			<pubDate>Mon, 17 Jun 2013 14:28:59 GMT</pubDate>
			<description><![CDATA[Hey guys, I've been hitting Java pretty hard in the past week, and am currently working on a small project to get familiar with different ins and...]]></description>
			<content:encoded><![CDATA[<div>Hey guys, I've been hitting Java pretty hard in the past week, and am currently working on a small project to get familiar with different ins and outs of Java. I have done some tinkering with databases, so I am a little familiar with SQL, PHP, GDBM (in C). In my current project, I am developing a very mind-less game (completely text-based). In the game,  would like to have quick access to dozens of items, and objects so I figured now would be as good as time as any to get familiar with a database.<br />
<br />
I have started with using Java to connect to a wamp server on my desktop, but would really like the database to be stored locally (on a flat file) so that I can move the game to a different platform without needing to install additional software.<br />
<br />
After googling for a bit, I can't seem to find an answer for a good flat file database that would let the program transfer from platform to platform and still be able to execute without other software.<br />
<br />
Does anyone have any knowledge of how I can achieve this with Java? Is there a particularly better flat file database than all the rest? Any input/direction would be appreciated! (Also tutorials would be magnificent!)<br />
<br />
Thanks!<br />
<br />
/edit: I'm developing in Eclipse, so anything that is built in NetBeans is still a little out of reach for me :)</div>

]]></content:encoded>
			<category domain="http://www.java-forums.org/new-java/">New To Java</category>
			<dc:creator>skania</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/new-java/78172-flat-file-database-java.html</guid>
		</item>
		<item>
			<title>Why does this always return null?</title>
			<link>http://www.java-forums.org/new-java/78152-why-does-always-return-null.html</link>
			<pubDate>Mon, 17 Jun 2013 13:22:36 GMT</pubDate>
			<description><![CDATA[It's a little hard to explain what I'm doing so I'll post the code first in separate methods: 
 
<div class="bbcode_container"> 
	<div...]]></description>
			<content:encoded><![CDATA[<div>It's a little hard to explain what I'm doing so I'll post the code first in separate methods:<br />
<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">//This gets a random itemstack depending on the player's amount of votes.<br />
&nbsp; &nbsp; &nbsp; &nbsp; public ItemStack get(Player p)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; OcoListener v = new OcoListener();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (v.votes.get(p.getName()) &gt;= 1 &amp;&amp; v.votes.get(p.getName()) &lt;= 5)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Random r = new Random();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int i = r.nextInt(5);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (i == 0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return new ItemStack(Material.COOKED_BEEF, new OcoListener().getAmount(this.get(p)));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }else if (i == 1)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return new ItemStack(Material.TNT, new OcoListener().getAmount(this.get(p)));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }else if (i == 2)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return new ItemStack(Material.ROTTEN_FLESH, new OcoListener().getAmount(this.get(p)));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }else if (i == 3)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return new ItemStack(Material.FLINT, new OcoListener().getAmount(this.get(p)));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }else<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return new ItemStack(Material.TORCH, new OcoListener().getAmount(this.get(p)));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }else if (v.votes.get(p.getName()) &gt;= 5 &amp;&amp; v.votes.get(p.getName()) &lt;= 15)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Random r = new Random();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int i = r.nextInt(10);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (i == 0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return new ItemStack(Material.COOKED_BEEF, new OcoListener().getAmount(this.get(p)));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }else if (i == 1)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return new ItemStack(Material.TNT, new OcoListener().getAmount(this.get(p)));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }else if (i == 2)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return new ItemStack(Material.ROTTEN_FLESH, new OcoListener().getAmount(this.get(p)));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }else if (i == 3)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return new ItemStack(Material.FLINT, new OcoListener().getAmount(this.get(p)));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }else if (i == 4)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return new ItemStack(Material.TORCH, new OcoListener().getAmount(this.get(p)));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }else if (i == 5)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return new ItemStack(Material.APPLE, new OcoListener().getAmount(this.get(p)));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }else if (i == 6)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return new ItemStack(Material.CLAY, new OcoListener().getAmount(this.get(p)));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }else if (i == 7)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return new ItemStack(Material.BUCKET, new OcoListener().getAmount(this.get(p)));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }else if (i == 8)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return new ItemStack(Material.GHAST_TEAR, new OcoListener().getAmount(this.get(p)));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }else<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return new ItemStack(Material.STRING, new OcoListener().getAmount(this.get(p)));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }else<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Random r = new Random();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int i = r.nextInt(20);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (i == 0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return new ItemStack(Material.COOKED_BEEF, new OcoListener().getAmount(this.get(p)));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }else if (i == 1)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return new ItemStack(Material.TNT, new OcoListener().getAmount(this.get(p)));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }else if (i == 2)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return new ItemStack(Material.ROTTEN_FLESH, new OcoListener().getAmount(this.get(p)));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }else if (i == 3)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return new ItemStack(Material.FLINT, new OcoListener().getAmount(this.get(p)));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }else if (i == 4)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return new ItemStack(Material.TORCH, new OcoListener().getAmount(this.get(p)));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }else if (i == 5)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return new ItemStack(Material.APPLE, new OcoListener().getAmount(this.get(p)));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }else if (i == 6)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return new ItemStack(Material.CLAY, new OcoListener().getAmount(this.get(p)));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }else if (i == 7)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return new ItemStack(Material.BUCKET, new OcoListener().getAmount(this.get(p)));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }else if (i == 8)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return new ItemStack(Material.GHAST_TEAR, new OcoListener().getAmount(this.get(p)));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }else if (i == 9)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return new ItemStack(Material.COCOA, new OcoListener().getAmount(this.get(p)));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }else if (i == 10)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return new ItemStack(Material.BOOK, new OcoListener().getAmount(this.get(p)));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }else if (i == 11)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return new ItemStack(Material.BLAZE_ROD, new OcoListener().getAmount(this.get(p)));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }else if (i == 12)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return new ItemStack(Material.EMERALD, new OcoListener().getAmount(this.get(p)));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }else if (i == 13)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return new ItemStack(Material.ARROW, new OcoListener().getAmount(this.get(p)));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }else if (i == 14)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return new ItemStack(Material.BREAD, new OcoListener().getAmount(this.get(p)));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }else if (i == 15)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return new ItemStack(Material.EGG, new OcoListener().getAmount(this.get(p)));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }else if (i == 16)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return new ItemStack(Material.WOOD, new OcoListener().getAmount(this.get(p)));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }else if (i == 17)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return new ItemStack(Material.CAKE, new OcoListener().getAmount(this.get(p)));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }else if (i == 18)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return new ItemStack(Material.BLAZE_POWDER, new OcoListener().getAmount(this.get(p)));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }else<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return new ItemStack(Material.REDSTONE, new OcoListener().getAmount(this.get(p)));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; }</code><hr />
</div><div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">//This is used for setting the quantity of the itemstack depending on its type.<br />
&nbsp; &nbsp; &nbsp; &nbsp; public int getAmount(ItemStack i)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (i.equals(new ItemStack(Material.COOKED_BEEF)))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return 12;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }else if (i.equals(new ItemStack(Material.TNT)))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return 32;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }else if (i.equals(new ItemStack(Material.ROTTEN_FLESH)))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return 24;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }else if (i.equals(new ItemStack(Material.FLINT)))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return 32;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }else if (i.equals(new ItemStack(Material.TORCH)))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return 64;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }else if (i.equals(new ItemStack(Material.APPLE)))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return 16;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }else if (i.equals(new ItemStack(Material.CLAY)))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return 32;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }else if (i.equals(new ItemStack(Material.BUCKET)))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return 3;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }else if (i.equals(new ItemStack(Material.GHAST_TEAR)))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return 4;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }else if (i.equals(new ItemStack(Material.COCOA)))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return 32;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }else if (i.equals(new ItemStack(Material.BOOK)))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return 64;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }else if (i.equals(new ItemStack(Material.BLAZE_ROD)))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return 6;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }else if (i.equals(new ItemStack(Material.EMERALD)))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return 4;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }else if (i.equals(new ItemStack(Material.ARROW)))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return 32;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }else if (i.equals(new ItemStack(Material.BREAD)))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return 12;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }else if (i.equals(new ItemStack(Material.EGG)))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return 8;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }else if (i.equals(new ItemStack(Material.WOOD)))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return 64;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }else if (i.equals(new ItemStack(Material.CAKE)))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return 1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }else if (i.equals(new ItemStack(Material.BLAZE_POWDER)))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return 6;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }else<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return 64;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; }</code><hr />
</div>This isn't as important:<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">//This method is used for getting the amount of times the for loop will run in the voteMade method above.<br />
&nbsp; &nbsp; &nbsp; &nbsp; public int getTimes(Player p)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; OcoListener v = new OcoListener();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (v.votes.get(p.getName()) &gt;= 1 &amp;&amp; v.votes.get(p.getName()) &lt;= 5)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return 2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }else if (v.votes.get(p.getName()) &gt;= 5 &amp;&amp; v.votes.get(p.getName()) &lt;= 10)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return 3;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }else<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return 4;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; }</code><hr />
</div>So basically, I'm trying to create a random itemstack depending on a player's votes. Each time it should generate a random item with a random amount, but it always returns null.<br />
<br />
Any idea why it would do that? I'm probably being stupid.<br />
<br />
If anyone wants to know, this is for when someone votes for the server and it sends a packet to it and gives them something for voting.<br />
<br />
v.votes.get(p.getName()) returns the amount of votes the player has, so the more times they vote the better things they get. But this happens whenever I try to make something similar to this:<br />
<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">int buySomething(Person guy)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (guy.getMoney() &gt; 250)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return guy.getMoney() - 250;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }else<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return guy.getMoney();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; guy.tell(&quot;You don't have enough money for that&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; }</code><hr />
</div></div>

]]></content:encoded>
			<category domain="http://www.java-forums.org/new-java/">New To Java</category>
			<dc:creator>ocomobock</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/new-java/78152-why-does-always-return-null.html</guid>
		</item>
		<item>
			<title>System Problem</title>
			<link>http://www.java-forums.org/new-java/78140-system-problem.html</link>
			<pubDate>Mon, 17 Jun 2013 12:07:47 GMT</pubDate>
			<description>Is it possible to create a *Bus Ticketing System* using Java? Cause that will be my project on finals. Hope it is :(think): and if it is really...</description>
			<content:encoded><![CDATA[<div>Is it possible to create a <b>Bus Ticketing System</b> using Java? Cause that will be my project on finals. Hope it is :(think): and if it is really possible, would you mind to teach me or send me a sample of that program so that I can learn on how to do it. Thanks in advance and Godbless!</div>

]]></content:encoded>
			<category domain="http://www.java-forums.org/new-java/">New To Java</category>
			<dc:creator>DPdieciocho</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/new-java/78140-system-problem.html</guid>
		</item>
		<item>
			<title>How to create a table in a text file and parse it into a Java Application</title>
			<link>http://www.java-forums.org/new-java/78139-how-create-table-text-file-parse-into-java-application.html</link>
			<pubDate>Mon, 17 Jun 2013 11:42:02 GMT</pubDate>
			<description>I have an assignment to do. I have to create a table of data(which is about Englisg Premier League) and in a table must contains: 
 
 
* Team Name....</description>
			<content:encoded><![CDATA[<div>I have an assignment to do. I have to create a table of data(which is about Englisg Premier League) and in a table must contains:<br />
<br />
<ul><li style="">Team Name.</li><li style="">Total number of games played to date.</li><li style="">Total number of games the team has won at home to date.</li><li style="">Total number of games the team has lost at home to date.</li><li style="">Total number of goals the team has scored at home to date.</li><li style="">Total number of goals the team has conceded at home to date.</li><li style="">Total number of games the team has won away from home to date.</li><li style="">Total number of games the team has drawn away from home to date.</li><li style="">Total number of games the team has lost away from home to date.</li><li style="">Total number of goals the team has scored away from home to date.</li><li style="">Total number of goals the team has conceded away from home to date.</li><li style="">Total number of points the team as accumulated to date.</li></ul>(I have no problem to find such details. )<br />
<br />
Once i have all of the details I need to put them into a table in a text file.<br />
So I don't quite understand how to create a table in a text file or i just have to create a simple text file and then convert it in to a table?<br />
I have no problem to read simple text file and display it on the Java Apllication but in this case i dont even know how to start off.<br />
<br />
Is any have any idea how to do it?<br />
Please advise me, I really need to know how to do it. Thanks :)-:</div>

]]></content:encoded>
			<category domain="http://www.java-forums.org/new-java/">New To Java</category>
			<dc:creator>wansai</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/new-java/78139-how-create-table-text-file-parse-into-java-application.html</guid>
		</item>
		<item>
			<title>How to run / embed a java file in jframe and other swing components in HTML page.</title>
			<link>http://www.java-forums.org/new-java/78092-how-run-embed-java-file-jframe-other-swing-components-html-page.html</link>
			<pubDate>Mon, 17 Jun 2013 05:45:34 GMT</pubDate>
			<description>How to run / embed a java file in jframe and other swing components in HTML page.  
 
Looking forward to your reply.  
 
Cheers</description>
			<content:encoded><![CDATA[<div>How to run / embed a java file in jframe and other swing components in HTML page. <br />
<br />
Looking forward to your reply. <br />
<br />
Cheers</div>

]]></content:encoded>
			<category domain="http://www.java-forums.org/new-java/">New To Java</category>
			<dc:creator>siddhartha</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/new-java/78092-how-run-embed-java-file-jframe-other-swing-components-html-page.html</guid>
		</item>
		<item>
			<title>Copy the folder with Java</title>
			<link>http://www.java-forums.org/new-java/78091-copy-folder-java.html</link>
			<pubDate>Mon, 17 Jun 2013 05:38:55 GMT</pubDate>
			<description>Hi 
How can I make folder from the path of the executable file to another copy.</description>
			<content:encoded><![CDATA[<div>Hi<br />
How can I make folder from the path of the executable file to another copy.</div>

]]></content:encoded>
			<category domain="http://www.java-forums.org/new-java/">New To Java</category>
			<dc:creator>teymoorei</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/new-java/78091-copy-folder-java.html</guid>
		</item>
		<item>
			<title>how to store row position of marix</title>
			<link>http://www.java-forums.org/new-java/78089-how-store-row-position-marix.html</link>
			<pubDate>Mon, 17 Jun 2013 05:14:35 GMT</pubDate>
			<description>hello all; 
            my matrix is 3*3 , i have a array now i want to store  row position in that array but i m unable to store row position can u...</description>
			<content:encoded><![CDATA[<div>hello all;<br />
            my matrix is 3*3 , i have a array now i want to store  row position in that array but i m unable to store row position can u help?</div>

]]></content:encoded>
			<category domain="http://www.java-forums.org/new-java/">New To Java</category>
			<dc:creator>stanish</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/new-java/78089-how-store-row-position-marix.html</guid>
		</item>
		<item>
			<title>Error with excuse generator</title>
			<link>http://www.java-forums.org/new-java/78068-error-excuse-generator.html</link>
			<pubDate>Mon, 17 Jun 2013 01:26:44 GMT</pubDate>
			<description><![CDATA[Now that I'm out of school, I've been doing a little coding here and there to keep it in my head, so I built an excuse generator. It builds two...]]></description>
			<content:encoded><![CDATA[<div>Now that I'm out of school, I've been doing a little coding here and there to keep it in my head, so I built an excuse generator. It builds two arrays from two text files; one for nouns, one for verbs. Then it follows the format &quot;My NOUN VERB my NOUN&quot;, and all the verbs end in &quot;ed&quot;, so it actually makes sense. The problem I'm having is with building the excuse. I just get &quot;My null null my null&quot;.<br />
<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">import java.util.*;<br />
import java.io.*;<br />
public class main {<br />
&nbsp; &nbsp; &nbsp; &nbsp; public static void main(String&#91;&#93; args) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Scanner inputNoun = new Scanner(System.in);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Scanner inputVerb = new Scanner(System.in);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; String excuse = null;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; String nounFile = &quot;nouns&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; String verbFile = &quot;verbs&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; String&#91;&#93; noun = new String&#91;2000&#93;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; String&#91;&#93; verbs = new String&#91;150&#93;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Random rand = new Random();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int j = rand.nextInt(2000);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int m = rand.nextInt(2000);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int n = rand.nextInt(150);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; try{<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; inputNoun = new Scanner(new File(nounFile));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; inputVerb = new Scanner(new File(verbFile));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }catch(Exception e){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; System.out.println(&quot;Couldn't find the file(s)&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for(int i = 0; i &lt; noun.length; i++){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; while(inputNoun.hasNextLine()){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; noun&#91;i&#93; = inputNoun.nextLine();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for(int x = 0; x &lt; verbs.length; x++){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; while(inputVerb.hasNextLine()){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; verbs&#91;x&#93; = inputVerb.nextLine();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; excuse = &quot;My &quot; + noun&#91;j&#93; + &quot; &quot; + verbs&#91;n&#93; + &quot; my &quot; + noun&#91;m&#93;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; System.out.println(excuse);<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
}</code><hr />
</div>Now, I tried replacing the index of the arrays in the format line with flat numbers, and it still gives me the same error. I have no idea what could be wrong, other than nothing being saved to the array, but I tested that earlier and it works just fine. Can anyone help?</div>

]]></content:encoded>
			<category domain="http://www.java-forums.org/new-java/">New To Java</category>
			<dc:creator>herpeslurpy</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/new-java/78068-error-excuse-generator.html</guid>
		</item>
		<item>
			<title>Help me with this bug (simple, code included)?</title>
			<link>http://www.java-forums.org/new-java/78044-help-me-bug-simple-code-included.html</link>
			<pubDate>Sun, 16 Jun 2013 21:54:44 GMT</pubDate>
			<description><![CDATA[I'm trying to make a game where you have to click get food from a vending machine, you have a budget and you need to get foods to match a quota (of...]]></description>
			<content:encoded><![CDATA[<div>I'm trying to make a game where you have to click get food from a vending machine, you have a budget and you need to get foods to match a quota (of saltiness...etc.) For some reason, when I draw the foods, I get a random image on the top left (candy on top of something else, and when I delete candy.png, another image replaces it). I've went over my code multiple and can't see how such a simple code could have a bug like that. Could you guys look over it and see what's wrong (ignore JFrame).</div>

]]></content:encoded>
			<category domain="http://www.java-forums.org/new-java/">New To Java</category>
			<dc:creator>Vorpike</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/new-java/78044-help-me-bug-simple-code-included.html</guid>
		</item>
		<item>
			<title>euler function problem</title>
			<link>http://www.java-forums.org/new-java/77994-euler-function-problem.html</link>
			<pubDate>Sun, 16 Jun 2013 12:27:06 GMT</pubDate>
			<description><![CDATA[Below is the question and my code. I don't know why its not working need some help 
  
*Question* 
Let S(n,m) = &#8721;&#966;(n × i) for 1 &#8804; i &#8804; m. (&#966; is...]]></description>
			<content:encoded><![CDATA[<div>Below is the question and my code. I don't know why its not working need some help<br />
 <br />
<b>Question</b><br />
Let S(n,m) = &#8721;&#966;(n × i) for 1 &#8804; i &#8804; m. (&#966; is Euler's totient function)<br />
You are given that S(510510,10^6 )= 45480596821125120.<br />
<br />
Find S(510510,10^11).<br />
<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">import java.math.BigInteger;<br />
<br />
public class TotientSum {<br />
<br />
&nbsp; &nbsp; private static final int n = 510510;<br />
<br />
&nbsp; &nbsp; private static String calculateSum(){<br />
&nbsp; &nbsp; &nbsp; &nbsp; BigInteger sum = null;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; for(BigInteger i= BigInteger.valueOf(10).pow(11);i.compareTo(BigInteger.ONE)&gt;0;i =i.subtract(BigInteger.ONE)){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sum=sum.add(totient(i.multiply(BigInteger.valueOf(n))));<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; return sum.toString();<br />
&nbsp; &nbsp; }<br />
&nbsp; &nbsp; private static BigInteger totient(BigInteger num) { <br />
&nbsp; &nbsp; &nbsp; &nbsp; int count = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; for (BigInteger a = BigInteger.ONE; a.compareTo(num)&lt;0; a=a.add(BigInteger.ONE)) { <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (gcd(num, a) == BigInteger.ONE) {&nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; count++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; return (BigInteger.valueOf(count));<br />
&nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; private static BigInteger gcd(BigInteger p, BigInteger q) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; while (q != BigInteger.ZERO) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; BigInteger temp = q;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; q = p.mod(q);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; p = temp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; return p;<br />
&nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; public static void main(String&#91;&#93; args) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; System.out.println(calculateSum());<br />
&nbsp; &nbsp; }<br />
}</code><hr />
</div></div>

]]></content:encoded>
			<category domain="http://www.java-forums.org/new-java/">New To Java</category>
			<dc:creator>CodeX Pro</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/new-java/77994-euler-function-problem.html</guid>
		</item>
		<item>
			<title>Shift Operators?</title>
			<link>http://www.java-forums.org/new-java/77946-shift-operators.html</link>
			<pubDate>Sun, 16 Jun 2013 05:39:25 GMT</pubDate>
			<description><![CDATA[Hi I am looking at the following code.I am really confused as to what the lines  
 
 sb.append(Character.forDigit((char)((c >>> 4) & 0x0f), 16)); 
...]]></description>
			<content:encoded><![CDATA[<div>Hi I am looking at the following code.I am really confused as to what the lines <br />
<br />
 sb.append(Character.forDigit((char)((c &gt;&gt;&gt; 4) &amp; 0x0f), 16));<br />
 sb.append(Character.forDigit((char)(c &amp; 0x0f), 16));<br />
<br />
are doing.Could someone please Clarify.<br />
<br />
Thanks<br />
<br />
<br />
public static String escape(String string) {<br />
        char c;<br />
        String s = string.trim();<br />
        StringBuffer sb = new StringBuffer();<br />
        int length = s.length();<br />
        for (int i = 0; i &lt; length; i += 1) {<br />
            c = s.charAt(i);<br />
            if (c &lt; ' ' || c == '+' || c == '%' || c == '=' || c == ';') {<br />
                sb.append('%');<br />
                sb.append(Character.forDigit((char)((c &gt;&gt;&gt; 4) &amp; 0x0f), 16));<br />
                sb.append(Character.forDigit((char)(c &amp; 0x0f), 16));<br />
            } else {<br />
                sb.append(c);<br />
            }<br />
        }<br />
        return sb.toString();<br />
    }</div>

]]></content:encoded>
			<category domain="http://www.java-forums.org/new-java/">New To Java</category>
			<dc:creator>bimtownboy</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/new-java/77946-shift-operators.html</guid>
		</item>
		<item>
			<title>Coding in inputs in Java</title>
			<link>http://www.java-forums.org/new-java/77904-coding-inputs-java.html</link>
			<pubDate>Sun, 16 Jun 2013 01:48:07 GMT</pubDate>
			<description>Hi fellow Java Lovers, 
I am currently programming a small game from the knowledge I know, and its just a basic game where you guide yourself around...</description>
			<content:encoded><![CDATA[<div>Hi fellow Java Lovers,<br />
I am currently programming a small game from the knowledge I know, and its just a basic game where you guide yourself around a haunted house and try to find the exit.<br />
Only problem is I don't know how to program user inputs into the program.<br />
<br />
eg. Here is a piece of my code<br />
&quot;<br />
protected void goRightThree()<br />
{<br />
	System.out.println(&quot;You walk forward, trying not to make too much noise&quot;);<br />
	System.out.println(&quot;You come to a left turn and right turn which way do you go?&quot;);<br />
	double randomNumber = Math.random();<br />
	if (randomNumber &gt;= 0.5)<br />
	{<br />
		System.out.println(&quot;You decide to go left&quot;);<br />
		System.out.println(&quot;&quot;);<br />
		goLeftFour();<br />
	}<br />
	<br />
	else<br />
	{<br />
		System.out.println(&quot;You decide to go right&quot;);<br />
		System.out.println(&quot;&quot;);<br />
		goRightFour();<br />
	}<br />
&quot;<br />
<br />
For the time being I just made the direction the user goes as a random decision but what I am aiming to do is make the user of this game be able to choose where he/she goes.<br />
I know people probably thinking I am very new to Java but help would be very nice.<br />
<br />
<br />
Thanks guys</div>

]]></content:encoded>
			<category domain="http://www.java-forums.org/new-java/">New To Java</category>
			<dc:creator>swamymonish</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/new-java/77904-coding-inputs-java.html</guid>
		</item>
		<item>
			<title>Help with using methods (Begginer)</title>
			<link>http://www.java-forums.org/new-java/77828-help-using-methods-begginer.html</link>
			<pubDate>Sat, 15 Jun 2013 15:30:07 GMT</pubDate>
			<description><![CDATA[We're supposed to use methods/functions in our program, but im having trouble incorporating them into it. My program is like a math game, asking...]]></description>
			<content:encoded><![CDATA[<div>We're supposed to use methods/functions in our program, but im having trouble incorporating them into it. My program is like a math game, asking simple addition and addition/subtraction questions. I want all the calculations to be in methods but i'm having trouble returning a whole equation back into the main method (sorry if that doesnt make sense, maybe the code will help better). <br />
<br />
I need some assistance when it comes to the direction I need to go in order to use methods effectively in my program, and where I should do my calculations! As well as what should be in its own methods and what should be in the main method. <br />
Thanks so much for the help!<br />
<br />
<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">import javax.swing.*;<br />
import java.io.*;<br />
<br />
<br />
public class SummativeTwo<br />
{<br />
&nbsp; public static void main (String&#91;&#93; args) throws IOException<br />
&nbsp; {<br />
&nbsp; &nbsp; BufferedReader myInput = new BufferedReader (new InputStreamReader (System.in));<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; Object&#91;&#93; options = {&quot;Yes! I'm Excited!&quot;,&quot;Im kind of nervous..&quot;,&quot;Now Way! Ewww!&quot;};<br />
&nbsp; &nbsp; &nbsp; int n = JOptionPane.showOptionDialog(null, &quot;Welcome Million Dollar Madness! &quot;+ &quot;Are you ready to play?&quot;,&quot;Welcome&quot;,JOptionPane.YES_NO_CANCEL_OPTION,JOptionPane.QUESTION_MESSAGE,null,options,options&#91;2&#93;);<br />
&nbsp; &nbsp; &nbsp; if (n == JOptionPane.YES_OPTION) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; JOptionPane.showMessageDialog(null,&quot;Okie Dokie! Lets get started!&quot;, &quot;Okie Dokie&quot;, JOptionPane.INFORMATION_MESSAGE);<br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; if (n == JOptionPane.NO_OPTION) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; JOptionPane.showMessageDialog(null,&quot;Aw thats okay! Im sure you'll have fun!&quot;, &quot;It's okay&quot;, JOptionPane.INFORMATION_MESSAGE);<br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; if (n == JOptionPane.CANCEL_OPTION) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; JOptionPane.showMessageDialog(null,&quot;Well too bad so sad! You're going to have to play anyways!&quot;, &quot;Too bad so sad&quot;, JOptionPane.INFORMATION_MESSAGE);<br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; Object&#91;&#93; optionsA = {&quot;Yes Please&quot;, &quot;Nope! I'm good!&quot;};<br />
&nbsp; &nbsp; &nbsp; int x = JOptionPane.showOptionDialog(null,&quot;Would you like to know the instructions for this game?&quot;,&quot;INSTRUCTIONS?&quot;, JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE,null,optionsA,optionsA&#91;0&#93;); <br />
&nbsp; &nbsp; &nbsp; if (x == JOptionPane.YES_OPTION) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; JOptionPane.showMessageDialog(null,&quot;There will be 3 levels in this game. As you go farther, the questions get harder and harder and each question \n. Each time you get a question right you will recieve a certain amount of money, which increases each time you pass each question. \n But be careful, because if you get 3 questions wrong in one level \n it's GAME OVER for you! Meaning you lose all your money. \n You may Cash Out at any point if you're not willing to risk losing the amount of money you have. Reach the end of \n the 3 levels and you take home all your money! \n GOOD LUCK!&quot;, &quot;Instructions&quot;, JOptionPane.INFORMATION_MESSAGE);<br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; if (x == JOptionPane.NO_OPTION) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; JOptionPane.showMessageDialog(null,&quot;Suit Yourself! Lets Start!&quot;, &quot;Your Choice&quot;, JOptionPane.INFORMATION_MESSAGE);<br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; JOptionPane.showMessageDialog(null,&quot;Welcome to Level: 1 &quot; ,&quot; level 1&quot;, JOptionPane.INFORMATION_MESSAGE);<br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; //LEVEL ONE<br />
&nbsp; &nbsp; &nbsp; int wrong = 0;<br />
&nbsp; &nbsp; &nbsp; int run = 1;<br />
&nbsp; &nbsp; &nbsp; int questionnum = 0;<br />
&nbsp; &nbsp; &nbsp; int amount = 500;<br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; while (run &lt;= 6 &amp;&amp; wrong != 3)<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; run ++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; questionnum++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int increment = 150;<br />
&nbsp; &nbsp; &nbsp; &nbsp; amount += 150;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; int numOne = additionOne ();<br />
&nbsp; &nbsp; &nbsp; &nbsp; int numTwo = additionTwo ();<br />
&nbsp; &nbsp; &nbsp; &nbsp; int answer = numOne + numTwo;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; String useranswerA = JOptionPane.showInputDialog(null,&quot;Question #&quot; + questionnum + &quot; is for: $&quot; + increment + &quot;\n&quot; + numOne + &quot; + &quot; + numTwo + &quot; = ?&quot;, &quot;Question&quot;, JOptionPane.INFORMATION_MESSAGE);<br />
&nbsp; &nbsp; &nbsp; &nbsp; useranswerA = myInput.readLine ();<br />
&nbsp; &nbsp; &nbsp; &nbsp; int useranswer = Integer.parseInt(useranswerA);<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; if (useranswer != answer)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; wrong ++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; JOptionPane.showMessageDialog(null,&quot;You got the wrong answer! \n The correct answer is: &quot; + answer + &quot; \n Questions Wrong: &quot; + wrong, &quot;Wrong Answer&quot;, JOptionPane.INFORMATION_MESSAGE);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int y = JOptionPane.showOptionDialog(null,&quot;CASH OUT with a total of $&quot; + amount + &quot;?&quot;,&quot;Cash Out?&quot;, JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE,null,optionsA,optionsA&#91;0&#93;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (y == JOptionPane.YES_OPTION) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; JOptionPane.showMessageDialog(null,&quot;Thanks for Playing!&quot;, &quot;Thank You!&quot;, JOptionPane.INFORMATION_MESSAGE);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; System.exit(0);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (y == JOptionPane.NO_OPTION) {}<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; else if (useranswer == answer)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; JOptionPane.showMessageDialog(null,&quot;Correct!&quot;, &quot;Right Answer&quot;, JOptionPane.INFORMATION_MESSAGE);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int y = JOptionPane.showOptionDialog(null,&quot;CASH OUT with a total of $&quot; + amount + &quot;?&quot;,&quot;Cash Out?&quot;, JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE,null,optionsA,optionsA&#91;0&#93;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (y == JOptionPane.YES_OPTION) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; JOptionPane.showMessageDialog(null,&quot;Thanks for Playing!&quot;, &quot;Thank You!&quot;, JOptionPane.INFORMATION_MESSAGE);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; System.exit(0);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (y == JOptionPane.NO_OPTION) {}<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; JOptionPane.showMessageDialog(null,&quot;LEVEL ONE COMPLETE!&quot;, &quot;LEVEL 1&quot;, JOptionPane.INFORMATION_MESSAGE);<br />
&nbsp; &nbsp; &nbsp; JOptionPane.showMessageDialog(null,&quot;Cash on Hand: $ &quot; + amount, &quot;Cash&quot;, JOptionPane.INFORMATION_MESSAGE);<br />
&nbsp; &nbsp; &nbsp; int y = JOptionPane.showOptionDialog(null,&quot;CASH OUT with a total of $&quot; + amount + &quot;?&quot;,&quot;Cash Out?&quot;, JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE,null,optionsA,optionsA&#91;0&#93;);<br />
&nbsp; &nbsp; &nbsp; if (y == JOptionPane.YES_OPTION) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; JOptionPane.showMessageDialog(null,&quot;Thanks for Playing!&quot;, &quot;Thank You!&quot;, JOptionPane.INFORMATION_MESSAGE);<br />
&nbsp; &nbsp; &nbsp; &nbsp; System.exit(0);<br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; if (y == JOptionPane.NO_OPTION) {}<br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; //LEVEL TWO<br />
&nbsp; &nbsp; &nbsp; JOptionPane.showMessageDialog(null,&quot;Welcome to Level: 2 &quot; ,&quot; level 2&quot;, JOptionPane.INFORMATION_MESSAGE);<br />
&nbsp; &nbsp; &nbsp; int wrongB = 0;<br />
&nbsp; &nbsp; &nbsp; int runB = 1;<br />
&nbsp; &nbsp; &nbsp; int questionnumB = 0;<br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; while (runB &lt;= 8 &amp;&amp; wrongB != 3)<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; runB ++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; questionnumB++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; amount += 250;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; int increment = 250;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; int numOne = additionOne ();<br />
&nbsp; &nbsp; &nbsp; &nbsp; int numTwo = additionTwo ();<br />
&nbsp; &nbsp; &nbsp; &nbsp; int numThree = numThree ();<br />
&nbsp; &nbsp; &nbsp; &nbsp; int answer = numOne + numTwo - numThree;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; String useranswerA = JOptionPane.showInputDialog(null,&quot;Question #&quot; + questionnum + &quot; is for: $&quot; + increment + &quot;\n&quot; + numOne + &quot; + &quot; + numTwo + &quot; - &quot; + numThree + &quot; = ?&quot;, &quot;Question&quot;, JOptionPane.INFORMATION_MESSAGE);<br />
&nbsp; &nbsp; &nbsp; &nbsp; useranswerA = myInput.readLine ();<br />
&nbsp; &nbsp; &nbsp; &nbsp; int useranswer = Integer.parseInt(useranswerA);<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; if (useranswer != answer)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; wrong ++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; JOptionPane.showMessageDialog(null,&quot;You got the wrong answer! \n The correct answer is: &quot; + answer + &quot; \n Questions Wrong: &quot; + wrongB, &quot;Wrong Answer&quot;, JOptionPane.INFORMATION_MESSAGE);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int z = JOptionPane.showOptionDialog(null,&quot;CASH OUT with a total of $&quot; + amount + &quot;?&quot;,&quot;Cash Out?&quot;, JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE,null,optionsA,optionsA&#91;0&#93;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (z == JOptionPane.YES_OPTION) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; JOptionPane.showMessageDialog(null,&quot;Thanks for Playing!&quot;, &quot;Thank You!&quot;, JOptionPane.INFORMATION_MESSAGE);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; System.exit(0);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (z == JOptionPane.NO_OPTION) {}<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; else if (useranswer == answer)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; JOptionPane.showMessageDialog(null,&quot;Correct!&quot;, &quot;Right Answer&quot;, JOptionPane.INFORMATION_MESSAGE);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int z = JOptionPane.showOptionDialog(null,&quot;CASH OUT with a total of $&quot; + amount + &quot;?&quot;,&quot;Cash Out?&quot;, JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE,null,optionsA,optionsA&#91;0&#93;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (z == JOptionPane.YES_OPTION) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; JOptionPane.showMessageDialog(null,&quot;Thanks for Playing!&quot;, &quot;Thank You!&quot;, JOptionPane.INFORMATION_MESSAGE);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; System.exit(0);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (z == JOptionPane.NO_OPTION) {}<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; JOptionPane.showMessageDialog(null,&quot;LEVEL TWO COMPLETE!&quot;, &quot;LEVEL 2&quot;, JOptionPane.INFORMATION_MESSAGE);<br />
&nbsp; &nbsp; &nbsp; int z = JOptionPane.showOptionDialog(null,&quot;CASH OUT with a total of $&quot; + amount + &quot;?&quot;,&quot;Cash Out?&quot;, JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE,null,optionsA,optionsA&#91;0&#93;);<br />
&nbsp; &nbsp; &nbsp; if (z == JOptionPane.YES_OPTION) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; JOptionPane.showMessageDialog(null,&quot;Thanks for Playing!&quot;, &quot;Thank You!&quot;, JOptionPane.INFORMATION_MESSAGE);<br />
&nbsp; &nbsp; &nbsp; &nbsp; System.exit(0);<br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; if (y == JOptionPane.NO_OPTION) {}<br />
&nbsp; &nbsp; }<br />
&nbsp; }<br />
&nbsp; <br />
&nbsp; public static int additionOne ()<br />
&nbsp; {<br />
&nbsp; &nbsp; int x = (int)( Math.random () * 30);<br />
&nbsp; &nbsp; return x;<br />
&nbsp; }<br />
&nbsp; public static int additionTwo ()<br />
&nbsp; {<br />
&nbsp; &nbsp; int x = (int)( Math.random () * 30);<br />
&nbsp; &nbsp; return x;<br />
&nbsp; }<br />
&nbsp; public static int numThree ()<br />
&nbsp; {<br />
&nbsp; &nbsp; int x = (int) (Math.random () * 15);<br />
&nbsp; &nbsp; return x;<br />
&nbsp; }<br />
}</code><hr />
</div></div>

]]></content:encoded>
			<category domain="http://www.java-forums.org/new-java/">New To Java</category>
			<dc:creator>maddiexc</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/new-java/77828-help-using-methods-begginer.html</guid>
		</item>
		<item>
			<title>JOptionPane looping?</title>
			<link>http://www.java-forums.org/new-java/77737-joptionpane-looping.html</link>
			<pubDate>Sat, 15 Jun 2013 08:52:24 GMT</pubDate>
			<description><![CDATA[<div class="bbcode_container"> 
	<div class="bbcode_description">Java Code: </div> 
 
	<pre class="brush: java">int nums[] = { 1, 2, 3, 4, 5, 6, 7,...]]></description>
			<content:encoded><![CDATA[<div><div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">int nums&#91;&#93; = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };<br />
int sum = 0;<br />
// use for-each style for to display and sum the values<br />
for(int x : nums) {<br />
JOptionPane.showMessageDialog(null,&quot;Value is: &quot; + x);<br />
sum += x;<br />
<br />
}</code><hr />
</div>here's my problem<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">JOptionPane.showMessageDialog(null,&quot;Value is: &quot; + x);</code><hr />
</div>it keeps saying the message &quot;Value is&quot; and initializing the JOptionPane everytime its looping into the array opposite to the output that i expected.<br />
<br />
the output i want is to put all the value in one optionpane.</div>

]]></content:encoded>
			<category domain="http://www.java-forums.org/new-java/">New To Java</category>
			<dc:creator>raffs03</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/new-java/77737-joptionpane-looping.html</guid>
		</item>
	</channel>
</rss>
