<?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 - Blogs</title>
		<link>http://www.java-forums.org/blogs/</link>
		<description>Java Programming Forum - Learning Java easily</description>
		<language>en</language>
		<lastBuildDate>Thu, 23 May 2013 12:25:15 GMT</lastBuildDate>
		<generator>vBulletin</generator>
		<ttl>60</ttl>
		<image>
			<url>http://www.java-forums.org/images/misc/rss.jpg</url>
			<title>Java Programming Forum - Learn Java Programming - Blogs</title>
			<link>http://www.java-forums.org/blogs/</link>
		</image>
		<item>
			<title>Homework help - Dice Roll</title>
			<link>http://www.java-forums.org/blogs/slick-java/1572-homework-help-dice-roll.html</link>
			<pubDate>Sat, 27 Apr 2013 23:03:05 GMT</pubDate>
			<description>---Quote (Originally by Slick Java)--- 
Hi, I am having trouble with this program. The point of this program is to roll a dice, store dice values in...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore"><div class="bbcode_container">
	<div class="bbcode_quote">
		<div class="quote_container">
			<div class="bbcode_quote_container"></div>
			
				<div class="bbcode_postedby">
					<img src="http://www.java-forums.org/images/misc/quote_icon.png" alt="Quote" /> Originally Posted by <strong>Slick Java</strong>
					<a href="showthread.php?p=332048#post332048" rel="nofollow"><img class="inlineimg" src="http://www.java-forums.org/images/buttons/viewpost-right.png" alt="View Post" /></a>
				</div>
				<div class="message">Hi, I am having trouble with this program. The point of this program is to roll a dice, store dice values in an array and print out how much time the value has been occurred. The output should be like this:<br />
<br />
1  3<br />
<br />
4  1<br />
<br />
5  1<br />
<br />
2  1<br />
<br />
But I am getting this:<br />
<br />
1  3<br />
<br />
4  1<br />
<br />
5  1<br />
<br />
1  3<br />
<br />
2  1<br />
<br />
1  3<br />
<br />
<br />
I am trying to find a way to get my expected result. The code is below.<br />
<br />
<br />
<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">package com.gavin.work;

import java.util.Random;

public class DiceRoll
{

    private final Random ran;

    int rolls;

    int numberOfDice = 1;

    int numberOfThrows = 6;

    int numberOfSides = 6;

    int&#91;&#93; counts = new int&#91;numberOfThrows&#93;;

    int&#91;&#93; occurences = new int&#91;numberOfSides * numberOfDice&#93;;

    public DiceRoll()
    {
        ran = new Random();

    }

    public static void main(String args&#91;&#93;)
    {
        DiceRoll d = new DiceRoll();
        d.go(Integer.parseInt(args&#91;0&#93;),
            Integer.parseInt(args&#91;1&#93;),
            Integer.parseInt(args&#91;2&#93;));

    }

    public int rollDice(int i)
    {
        return ran.nextInt(numberOfSides) + 1 * i;
    }

    public void go(int i, int j, int p)
    {
        numberOfDice = i;
        numberOfThrows = j;
        numberOfSides = p;
        doWork();

    }

    public void printAmounts()
    {
        System.out.printf(&quot;%d \n %d \n %d&quot;, numberOfDice, numberOfThrows,
            numberOfSides);
    }


    public void doWork()
    {
        for (int h = 0; h &lt; occurences.length; h++)
        {
            occurences&#91;h&#93; = 0;
        }

        for (int i = 0; i &lt; counts.length; i++)
        {
            counts&#91;i&#93; = rollDice(numberOfDice);
        }

        for (int i : counts)
        {
            for (int j = 0; j &lt; occurences.length; j++)
            {
                if (counts&#91;j&#93; == i)
                {
                    occurences&#91;j&#93; = occurences&#91;j&#93; + 1;
                }
            }
        }

        for (int k = 0; k &lt; counts.length; k++)
        {
            System.out.printf(&quot;%d  %d\n\n&quot;, counts&#91;k&#93;, occurences&#91;k&#93;);
        }

    }

}</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div></div>
			
		</div>
	</div>
</div></blockquote>

]]></content:encoded>
			<dc:creator>Slick Java</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/slick-java/1572-homework-help-dice-roll.html</guid>
		</item>
		<item>
			<title>Future Cheat Sheets</title>
			<link>http://www.java-forums.org/blogs/penguincoder/1569-future-cheat-sheets.html</link>
			<pubDate>Tue, 30 Oct 2012 19:38:26 GMT</pubDate>
			<description>Just trying to think of the topics that I want to create cheat sheets about.  In the next few weeks I plan on making many more of these, here are a...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">Just trying to think of the topics that I want to create cheat sheets about.  In the next few weeks I plan on making many more of these, here are a few topics that I think I will start with:<br />
<ul><li style="">Linked Lists</li><li style="">Abstract Data Types</li><li style="">Abstract Algorithmic Analysis</li><li style="">AWT Event Handling</li><li style="">Swing Components</li><li style="">Swing Event Handling?</li><li style="">Inheritance</li><li style="">Polymorphism</li><li style="">Interfaces</li><li style="">Exception Handling</li></ul><br />
<br />
<br />
This is in no particular order, and I will probably be hopping around this list for the next week or two.  If there is a topic that you wish to be on the list, please leave a comment below.<br />
<br />
<br />
**This post will be deleted after I get a majority of these made; it is just a reference chart for myself since I seem to hop from computer to computer (one of the detriments to having multiple computers) and felt it would be more beneficial to have online then to have on a hard drive.</blockquote>

]]></content:encoded>
			<dc:creator>penguinCoder</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/penguincoder/1569-future-cheat-sheets.html</guid>
		</item>
		<item>
			<title>File Input Output Cheat Sheet</title>
			<link>http://www.java-forums.org/blogs/penguincoder/1568-file-input-output-cheat-sheet.html</link>
			<pubDate>Tue, 30 Oct 2012 03:18:15 GMT</pubDate>
			<description><![CDATA[File Input Output Cheat Sheet 
 
*Importing Libraries* 
The primary library that deals with files: 
<div class="bbcode_container"> 
	<div...]]></description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">File Input Output Cheat Sheet<br />
<br />
<b>Importing Libraries</b><br />
The primary library that deals with files:<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">import java.io.File;</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 The library that deals with writing to files:<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">import java.io.PrintWriter;</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <br />
<b>FYI</b><br />
If there is more then one type of information that is being transferred to or from a file, it is usually best to use a record; IMO.<br />
<br />
<br />
<div style="text-align: center;"><b>Writing to a File</b></div><br />
<b>Declare and Allocate a File Instance</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">File fileVarName = new File(&quot;path/to/file.txt&quot;);</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 This file path is based on the Linux File Systems, Windows users :(n): will have to specify c:\path\file.txt<br />
<br />
<b>Declare and Allocate a PrintWriter Instance</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">PrintWriter printVarName = new PrintWriter(fileVarName);</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 [b]Writing to the File[b]<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">printVarName.println(&quot;penguinCoder&quot;);
printVarName.println(848.2884);
printVarName.println(false);</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <b>De-Allocating the PrintWriter Instance</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">printVarName.close();</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <br />
<br />
<div style="text-align: center;"><b>Reading From a File</b></div><br />
<b>Declare and Allocate a File Instance</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">File fileVarName = new File(&quot;path/to/file.txt&quot;);</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 This file path is based on the Linux File Systems, Windows users :( will have to specify c:\path\file.txt<br />
<br />
<b>Declare and Allocate a Scanner Instance</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">Scanner keyboard = new Scanner(fileVarName);</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <b>Checking if there is a next line to be read</b><br />
Returns true if there is another line, returns false if it is the final line.<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">keyboard.hasNext();</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <b>Reading the next line</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">keyboard.nextLine();</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <b>Reading the next Integer</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">keyboard.nextInt();</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <b>Reading the next Double</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">keyboard.nextDouble();</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <b>Reading the next String</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">keyboard.next();</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <b>Reading the next Character</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">keyboard.next().charAt(0);</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <b>De-Allocating the Scanner Instance</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">keyboard.close();</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <br />
<br />
<div style="text-align: center;"><b>Checking if File Exists</b></div><div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">File fileVarName = new File(&quot;file/path/name.txt&quot;);

if( fileVarName.exists() ){
  ...code...
}
else
  System.out.println(&quot;That file does not exist&quot;);</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <br />
<br />
<div style="text-align: center;"><b>Deleting a File</b></div><div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">File fileVarName = new File(&quot;file/path/name.txt&quot;);

if( fileVarName.exists() ){
  fileVarName.delete();
  System.out.println(fileVarName + &quot; has been deleted.&quot;);
}
else
  System.out.println(&quot;That file does not exist&quot;);</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 </blockquote>

]]></content:encoded>
			<dc:creator>penguinCoder</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/penguincoder/1568-file-input-output-cheat-sheet.html</guid>
		</item>
		<item>
			<title>AWT Component Cheat Sheet</title>
			<link>http://www.java-forums.org/blogs/penguincoder/1567-awt-component-cheat-sheet.html</link>
			<pubDate>Tue, 30 Oct 2012 01:15:55 GMT</pubDate>
			<description>AWT Components Cheat Sheet 
 
*Importing Libraries* 
There are two main libraries that involve the AWT tools.  This package contains the core AWT...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">AWT Components Cheat Sheet<br />
<br />
<b>Importing Libraries</b><br />
There are two main libraries that involve the AWT tools.  This package contains the core AWT graphics classes.  Contains component classes for buttons, text fields, labels, frames, panels, dialogs, and scroll panes.  It also contains the layout managers such as flow layout, border layout, and grid layout.  Also included are the cusrom graphics classes such as graphics, color and font.<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">import java.awt.*;</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <br />
<b>Common AWT Components</b><br />
<ul><li style="">TextField</li><li style="">Button</li><li style="">Label</li><li style="">List</li><li style="">Choice</li><li style="">CheckBox</li></ul><br />
<br />
<img src="http://www.java-forums.org/attachment.php?attachmentid=4185&amp;d=1351564334" border="0" alt="Name:  AWT_Components.png
Views: 263
Size:  58.9 KB" class="thumbnail" style="float:CONFIG" /><br />
<br />
<br />
<div style="text-align: center;"><b><font size="4">Label</font></b></div><br />
<b>Declare and allocate a Label instance.</b><br />
<b>Basic w/ No String</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">Label varName = new Label();</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <b>Basic w/ String:</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">Label varName = new Label(&quot;This is a label&quot;);</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <b>With alignment:</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">Label varName = new Label(&quot;This is a label&quot;, Label.CENTER);</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <b>Add the label to a container:</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">containerName.add(varName);</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <b>Modify the label's text string:</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">varName.setText(&quot;This is the new label&quot;);</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <b>Retrieve the label's text string:</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">varName.getText();</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <b>Anonymous Instance</b><br />
This allows for an easier method, but you cannot modify the label in the future portion of the program if you use this method.<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">componentName.add( new Label (&quot;This is the label&quot;, Label.RIGHT) );</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <b>This is the same as doing:</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">Label varName = new Label(&quot;This is the label&quot;, Label.RIGHT);
componenetName.add(varName);</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <br />
<div style="text-align: center;"><font size="4"><b>Button</b></font></div><br />
<b>Declare and allocate a button instance:</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">Button varName = new Button(&quot;This is a button&quot;);</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <b>Add the button to a container:</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">containerName.add(varName);</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <b>Modify the button's label:</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">varName.setLabel(&quot;This is the new button label&quot;);</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <b>Retrieve the button's label:</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">varName.getLabel();</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 Anonymous Instance<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">add(Button (&quot;Button Label&quot;) );</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <br />
<div style="text-align: center;"><font size="4"><b>Text Field</b></font></div><br />
<b>Declare and allocate a TextField instance.</b><br />
<b>Given initial text and column width:</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">TextField varName = new TextField(&quot;Initial Text&quot;, 20);</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <b>Given just initial text:</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">TextField varName = new TextField(&quot;Initial Text&quot;);</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <b>Given true (editable) or false (non-editable)</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">TextField varName = new TextField(boolean);</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <b>Add the TextField to a container:</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">containerName.add(varName);</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <b>Modify the TextField's label:</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">varName.setText(&quot;New initial text&quot;);</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <b>Retrieve the TextField's label:</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">varName.getText();</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <b>Modifying Editable(true) or Non-Editable(false):</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">varName.setEditable(boolean)</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <b>Retrieving Integer from TextField</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">int number = Integer.parseInt( varName.getText() );</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <b>Inputting an Integer into TextField</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">varName.setText(number + &quot;&quot;);</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <br />
<b>Things that Pertain to Below Methods</b><br />
<b>Declare and allocate a Font instance:</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">Font textFont = new Font(&quot;SansSerif&quot;, Font.BOLD, 14);</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <b>Available Default Colors:</b><br />
Red, Magenta, Blue, Cyan, Green, Yellow, White, Gray, and Black.<br />
<br />
<br />
<div style="text-align: center;"><font size="4"><b>List</b></font></div><br />
<b>Declare and allocate a List instance.</b><br />
<b>Empty List instance with 4 default visible rows:</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">List varName = new List();</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <b>Empty List instance with defined number of visible rows:</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">List varName = new List(rows#);</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <b>Empty List instance with defined number of visible rows and specified MultiSelect switch:</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">List varName = new List(rows#, boolean);</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <b>Add String into Next Available Slot:</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">varName.add(&quot;This is the next item&quot;);</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <b>Add String into Specified Slot:</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">varName.add(&quot;This is an item&quot;, index#);</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <b>Sets Background Color of List:</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">varName.setBackground(colorName);</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <b>Sets the Font for the Entire List:</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">varName.setFont(FontText);</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <b>Sets the Font Color of the Entire List:</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">varName.setForeground(colorName);</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <b>Set Default Selected Item:</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">varName.Select(index#);</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <b>Add the List to a container:</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">containerName.add(varName);</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <b>Set Event Handler for the List:</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">varName.addItemListener(ItemListenerName);</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <br />
<div style="text-align: center;"><font size="4"><b>Choice</b></font></div><br />
<b>Declare and allocate a Choice instance:</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">Choice varName = new Choice ();</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <b>Add String into Specified Slot:</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">varName.insert(&quot;This is an item&quot;, index#);</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <b>Return a Specified Item:</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">varName.getSelectedIndex(index#);</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <b>Sets Background Color of Choice:</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">varName.setBackground(colorName);</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <b>Sets the Font for the Entire Choice:</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">varName.setFont(FontText);</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <b>Sets the Font Color of the Entire Choice:</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">varName.setForeground(colorName);</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <b>Set Default Selected Item:</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">varName.Select(index#);</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <b>Set Event Handler for the Choice:</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">varName.addItemListener(ItemListenerName);</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <b>Add the Choice to a container:</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">containerName.add(varName);</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <br />
<div style="text-align: center;"><font size="4"><b>Checkbox</b></font></div><br />
<b>Declare and allocate a Checkbox instance.</b><br />
<b>Blank Checkbox instance:</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">Checkbox varName = new Checkbox();</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <b>Checkbox instance with specified text:</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">Checkbox varName = new Checkbox(&quot;This is a check box&quot;);</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <b>Checkbox instance with specified text and default selected(true) or non-selected(false) state:</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">Checkbox varName = new Checkbox(&quot;This is a check box&quot;, boolean);</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <b>Checkbox instance with specified text and default selected(true) or non-selected(false) state that is part of a group of Checkboxes, and will apear as Radio Buttons:</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">Checkbox varName = new Checkbox(&quot;This is a check box&quot;, groupName, boolean);</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <b>Modify the label of a Checkbox:</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">varName.setLabel(&quot;This is the new label for the check box&quot;);</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <b>Sets Background Color of Checkbox:</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">varName.setBackground(colorName);</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <b>Sets the Font for the Checkbox:</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">varName.setFont(FontText);</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <b>Set Default Selected(true) or Un-selected(false):</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">varName.setSelected(boolean);</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <b>Set Event Handler for the Choice:</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">varName.addItemListener(ItemListenerName);</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <b>Returns the State, Checked(true) or Not Checked(false):</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">varName.isSelected();</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <b>Add the Checkbox to a container:</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">containerName.add(varName);</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 </blockquote>

]]></content:encoded>
			<dc:creator>penguinCoder</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/penguincoder/1567-awt-component-cheat-sheet.html</guid>
		</item>
		<item>
			<title>ArrayList Cheat Sheet</title>
			<link>http://www.java-forums.org/blogs/penguincoder/1566-arraylist-cheat-sheet.html</link>
			<pubDate>Mon, 29 Oct 2012 10:17:15 GMT</pubDate>
			<description><![CDATA[*Importing the Library* 
Before you can use an ArrayList, you must first import the necessary library. 
<div class="bbcode_container"> 
	<div...]]></description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore"><b>Importing the Library</b><br />
Before you can use an ArrayList, you must first import the necessary library.<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">import java.util.ArrayList</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <b>Creating a Generic ArrayList</b><br />
Generic ArrayList is an ArrayList with a type; no other type is allowed to be inserted into the ArrayList.<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">ArrayList&lt;type&gt; listName = new ArrayList&lt;type&gt;();</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 Example of this would be:<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">ArrayList&lt;String&gt; myArrayList = new ArrayList&lt;String&gt;();</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <br />
<b>Creating Non-Generic ArrayList</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">ArrayList listName = new ArrayList();</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 An example of this would be:<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">ArrayList myArrayList = new ArrayList();</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <br />
<b>Note</b><br />
You do not need to build the ArrayList to any mentioned size, as it will automatically expand.  This however is not recomended, as it will take many additional resources to accomplish this.  Each time the ArrayList needs to expand, it creates a new ArrayList, and copies all of the contents to the new ArrayList, using the System.arrayCopy() method.  As you can tell, this would eat up alot of additional resources.<br />
<br />
<br />
<b>Creating ArrayList with a Size</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">ArrayList&lt;type&gt; listName = new ArrayList&lt;type&gt;(size);
ArrayList listName = new ArrayList(size);</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 An example of this would be:<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">ArrayList&lt;String&gt; myArrayList = new ArrayList&lt;String&gt;(50);
ArrayList myArrayList = new ArrayList(50);</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <br />
<br />
<br />
An ArrayList has a host of different methods that are associated with it that allow the programmer to modify it.  Here are a few I have used, and examples of each.<br />
<br />
<br />
<b>Adding an Item</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">listName.add(item);</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 An example of this would be:<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">myArrayList.add(&quot;penguin&quot;);</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <br />
<b>Removing an Item</b><br />
You can specify either the item, or the index number to remove an item from an ArrayList.<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">listName.remove(index);
listName.remove(item);</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 An example of this would be:<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">myArrayList.remove(0);
myArrayList.remove(&quot;penguin&quot;);</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <br />
<b>Replacing an Item</b><br />
You must specify the index and the new item that is going to replace the old item.<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">listName.set(index, item);</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 An example of this would be:<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">myArrayList.set(0, &quot;tux&quot;);</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <br />
<b>Checking the Size</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">listName.size();</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 An example of this would be:<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">int size = myArrayList.size();</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <br />
<b>Searching ArrayList</b><br />
This will only return the index of the first occurance of whatever it is you are searching for.<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">listName.indexOf(item);</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 An example of this would be:<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">int ix = myArrayList.indexOf(&quot;penguin&quot;);</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <br />
<b>Verifying Contents</b><br />
This will return a boolean true or false depending upon if the ArrayList does, or does not, contain what you are looking for.<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">listName.contains(item);</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 An example of this would be:<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">if( myArrayList.contains(&quot;penguin&quot;) )</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <br />
<b>Checking if Empty</b><br />
This will return a boolean true if the ArrayList is empty.<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">listName.isEmpty();</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 An example of this would be:<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">while( myArrayList.isEmpty() );</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <br />
<b>Copying a Whole ArrayList</b><br />
After creating a new ArrayList, you can copy the contents of an existing ArrayList to the new one.<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">newListName.addAll(listName);</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 An example of this would be:<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">ArrayList&lt;String&gt; copyArrayList = new ArrayList&lt;String&gt;();
copyArrayList.addAll(myArrayList);</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <br />
<b>Clearing an ArrayList</b><br />
You can clear the entire contents of an ArrayList.<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">listName.clear();</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 An example of this would be:<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">myArrayList.clear();</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <br />
<b>Sorting an ArrayList</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">Collections.sort(listName);</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 An example of this would be:<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">Collections.sort(myArrayList);</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <br />
<b>Outputing an ArrayList</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">for( &lt;type&gt; varName : listName )
  System.out.println(varName);</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <br />
An example of outputting a Generic ArrayList would be:<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">for( String ix : myArrayList )
  System.out.println(ix);</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 An example of outputting a Non-Generic ArrayList would be:<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">for(Object ix : myArrayList )
  System.out.println(ix);</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <br />
<b>Conversion</b><br />
There might be times when you will need to convert an ArrayList to an ordinary array, or convery an ordinary array to an ArrayList.<br />
<br />
<b>ArrayList to an Array</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">listName.toArray(arrayName);</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 An example of this would be:<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">String&#91;&#93; regArray = new String&#91;myArrayList.size()&#93;;
myArrayList.toArray(regArray);</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <br />
<b>Array to an ArrayList</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">ArrayList listName = Array.asList(arrayName)</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 An example would be:<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">ArrayList&lt;String&gt; myArrayList = Arrays.asList(regArray);</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 </blockquote>

]]></content:encoded>
			<dc:creator>penguinCoder</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/penguincoder/1566-arraylist-cheat-sheet.html</guid>
		</item>
		<item>
			<title>Virtual Memory Cheat Sheet</title>
			<link>http://www.java-forums.org/blogs/penguincoder/1565-virtual-memory-cheat-sheet.html</link>
			<pubDate>Sat, 27 Oct 2012 02:39:22 GMT</pubDate>
			<description><![CDATA[*Brief Description*: 
'Virtual' Memory is the mental model, or abstraction, that the programming language provides to the programmer to explain how...]]></description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore"><b>Brief Description</b>:<br />
'Virtual' Memory is the mental model, or abstraction, that the programming language provides to the programmer to explain how computer memory is managed while you program is running.  It is NOT the same as physical memory.<br />
<br />
<b>Run Time</b>:<br />
At run time, the operating system handles the translation from 'virtual' memory addresses to physical memory addresses, and the programmer does no need to be aware of this process.<br />
<br />
<b>Static Region</b>:<br />
This is referred to as the top.<br />
Is called the Static Region because the contents of each location do not change while the program is running.<br />
It contains the code for the program.<br />
Also contains static data members.<br />
The size of this region does not change.<br />
<br />
<b>Heap Region</b><br />
This is referred to as the middle.<br />
Is used for dynamically allocated storage, anything that is created with the keyword 'new'.<br />
Storage in this region is reserved while the program is running.<br />
The same location can be allocated once, then released, and then re-used for something else, over and over; all while the program is running.<br />
NOT to be confused with the Abstract Data Type called 'heap'.<br />
<br />
<b>Stack Region</b><br />
This is referred to as the bottom.<br />
This is where local variables are stored.<br />
Storage is reserved when the method is called, and released when the method exits.<br />
Conceptually, storage is reserved from the bottom up.<br />
When a method is called, the Stack 'grows'.<br />
When a method exits, the Stack 'shrinks'.<br />
Since the last method called is the next to exit, this is a Last-In First-Out Process.<br />
The same location on the stack may be occupied by different variables throughout program execution.</blockquote>

]]></content:encoded>
			<dc:creator>penguinCoder</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/penguincoder/1565-virtual-memory-cheat-sheet.html</guid>
		</item>
		<item>
			<title>Records Cheat Sheet</title>
			<link>http://www.java-forums.org/blogs/penguincoder/1564-records-cheat-sheet.html</link>
			<pubDate>Sat, 27 Oct 2012 02:25:44 GMT</pubDate>
			<description>*Brief Description*: 
A record is pretty much just a programmer defined data type.  It combines one or more pieces of information, or potentially...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore"><b>Brief Description</b>:<br />
A record is pretty much just a programmer defined data type.  It combines one or more pieces of information, or potentially different data types, into one unit.  Structure wise, it is just a template that defines how to interpret the contents of a sequence of memory locations.<br />
<br />
First outside of any class, <b>define the new data type</b>:<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">class recordName{
  public &#91;dataType&#93; fieldName;
  ..repeat for any number of types..
}</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <b>An example</b> of this would be:<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">class Employee{
  public String name;
  public int ID;
  public double salary;
}</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 Inside of the class you wish to use the record, <b>declare a variable of that type</b>:<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">recordName variableName;</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <b>An example</b> of this would be:<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">public static void main(String&#91;&#93; args){
  Employee jon;</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <b>Create storage for that instance, and assign a reference to that storage location to a variable of that type</b>:<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">variableName = new recordName;</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <b>An example</b> would be:<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">jon = new Employee;</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 Last thing you have to do is just <b>assign values to the fields of the record</b>, one by one:<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">variableName.fieldName = value;</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <b>An example</b> of this would be:<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">jon.name = &quot;Jon Johnson&quot;;
jon.ID = 11223344;
jon.salary = 55000;</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <b>To use any of these values</b>:<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">System.out.println(variableName.fieldName);</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <b>An example</b> of this would be:<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">System.out.println(&quot;Employee Name: &quot; + jon.name);
System.out.println(&quot;Employee ID: &quot; + jon.ID);
System.out.println(&quot;Employee Salary: &quot; + jon.salary);</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 </blockquote>

]]></content:encoded>
			<dc:creator>penguinCoder</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/penguincoder/1564-records-cheat-sheet.html</guid>
		</item>
		<item>
			<title>Random Number Cheat Sheet</title>
			<link>http://www.java-forums.org/blogs/penguincoder/1563-random-number-cheat-sheet.html</link>
			<pubDate>Sat, 27 Oct 2012 02:00:38 GMT</pubDate>
			<description>Just for FYI, computers cannot generate actual random numbers.  They are machines, and they do what they are told; and therefore cannot just choose a...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">Just for FYI, computers cannot generate actual random numbers.  They are machines, and they do what they are told; and therefore cannot just choose a number at random.  Mathematicians would call the process this process 'psuedo-random' number generation, but I didn't feel that made a good title so, whatever..  Just covering all the bases.<br />
<br />
First you will have to import the library:<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">import java.util.Random;</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 Next, you create a random number generator; most of the time is it made a static data member so that it can be shared by all the methods:<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">private static Random generator;</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 The keyword 'generator' is just the variable name, and can be changed to whatever you see fit; but it is good practice to choose descriptive variable names.<br />
<br />
After that you will have to initialize your new generator:<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">generator = new Random();</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 This can be done at the same time as when 'generator' is created, like:<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">private static Random generator = new Random();</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 To generate one random integer:<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">int nextInt;
nextInt = generator.nextInt();</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 To generate one random integer from 0 up to, but NOT including MAX:<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">final int MAX = 24;
int nextInt;
nextInt = generator.nextInt(MAX);</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 To generate one random integer between 1 through MAX:<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">final int MAX = 24;
int nextInt;
nextInt = generator.nextInt(MAX) +1;</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 To generate one real number from 0 up to, but NOT including 1:<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">double nextDouble;
nextDouble = generator.nextDouble();</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 To generate one real number from 0 up to, but NOT including MAX:<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">final double MAX = 100;
double nextDouble;
nextDouble = generator.nextDouble() * MAX;</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 </blockquote>

]]></content:encoded>
			<dc:creator>penguinCoder</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/penguincoder/1563-random-number-cheat-sheet.html</guid>
		</item>
		<item>
			<title>Scanner Class Cheat Sheet</title>
			<link>http://www.java-forums.org/blogs/penguincoder/1562-scanner-class-cheat-sheet.html</link>
			<pubDate>Wed, 17 Oct 2012 22:26:25 GMT</pubDate>
			<description>The Scanner class can be used for many things other then just getting input from the user; however this cheat sheet/tutorial is just going to be...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore"><i>The Scanner class can be used for many things other then just getting input from the user; however this cheat sheet/tutorial is just going to be about getting input from the user.</i><br />
<br />
<b>Defining the Scanner Class</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">import java.util.Scanner;

public class ClassName{
  ...code...
}</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 It will tell the translator to look in that directory for the code defining the Scanner class.<br />
<br />
<br />
<b>Declaring the Scanner</b><br />
If you are just going to use the Scanner class inside of the main method, it should be declared inside of the main method.<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">public class ClassName{
  public static void main(String&#91;&#93; args){
    Scanner keyboard;
    ...code...</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 If you are going to be using the Scanner class within multiple methods, inside of the same class, you should then define it as a static data member.<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">public class ClassName{
  public static Scanner keyboard;

  public static void main(String&#91;&#93; args){
    ...code...</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 These are variable declaration with<br />
<ul><li style="">the data type as 'Scanner'</li><li style="">the variable name as 'keyboard'</li></ul><br />
This variable will contain a reference to an instance of a Scanner.<br />
<br />
<br />
<b>Creating an instance of Scanner</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">keyboard = new Scanner( System.in );</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 Most of the time an instance of Scanner is created at the same time it is declared.<br />
<br />
The keyword 'new' dynamically allocates storage for an instance of the Scanner. It also initializes the new instance. The new Scanner is attached to the standard input stream from the keyboard ('System.in'). The Scanner can also read from ASCII text files. It also returns the address of the storage in memory, and assigns this address to the Scanner variable.<br />
<br />
<br />
<b>Calling Functions of the Scanner Class</b><br />
<br />
<b>For Integers</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">int count;
System.out.println(&quot;Enter count: &quot;);
count = keyboard.nextInt();</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <b>For Floats</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">float cost;
System.out.println(&quot;Enter cost: &quot;);
cost = keyboard.nextFloat();</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <b>For Doubles</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">double distance;
System.out.println(&quot;Enter distance: &quot;);
distance = keyboard.nextDouble();</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <b>For Strings with NO Spaces</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">String lastName;
System.out.println(&quot;Enter last name: &quot;);
lastName = keyboard.next();</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <b>For Strings WITH Spaces</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">String name;
System.out.println(&quot;Enter full name: &quot;);
name = keyboard.nextLine();</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <b>For Characters</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">char response;
System.out.println(&quot;Again? (y/n)&quot;);
response = keyboard.next().charAt(0);</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 Another little trick of the Scanner class is when you are displaying more then a page of information, you might want to prompt the user before the information runs off the page.<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">System.out.println(&quot;Press Enter to Continue&quot;);
keyboard.nextLine();
keyboard.nextLine();</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 </blockquote>

]]></content:encoded>
			<dc:creator>penguinCoder</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/penguincoder/1562-scanner-class-cheat-sheet.html</guid>
		</item>
		<item>
			<title>String Cheat Sheet</title>
			<link>http://www.java-forums.org/blogs/penguincoder/1561-string-cheat-sheet.html</link>
			<pubDate>Wed, 17 Oct 2012 22:05:34 GMT</pubDate>
			<description>A string is a piece of text, that is zero or more characters in length. In Java, strings are considered to be pre-built objects. The variable for a...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">A string is a piece of text, that is zero or more characters in length. In Java, strings are considered to be pre-built objects. The variable for a string does not store the value of the string, rather it is a reference point, or pointer, to the storage location of where the string is kept.<br />
<br />
<br />
<b>Declaring a String:</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">String s1;</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <b>Assigning a Value On Declaration:</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">String s1 = &quot;Hello World!&quot;;</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <b>Assigning a Value With Assignment</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">String s1;
s1 = &quot;Hello World!&quot;;</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <b>Assigning a Value With Input</b><br />
[code]<br />
String s1;<br />
s1 = keyboard.next();<br />
[code]<br />
<br />
<br />
<div style="text-align: center;"><b>Common String Methods</b></div><br />
The string class is 'immutable', which means that none of the different methods that strings use can change what is actually stored within the string itself. When methods alter a string, rather then saving it in the same storage location, it chooses a new storage location, and leaves the original unchanged. Any method that seems to change a string's contents is actually producing a modified version in an independent storage.<br />
<br />
<br />
<b>To identify how many characters reside in a particular strings, use the following method.</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">int len;
String s1;
len = s1.length();</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 This will store the number of characters that are stored in the string s1 and store that number in the integer len.<br />
Individual Character<br />
<br />
<br />
<b>You are able to extract single characters from within a string, and you can even choose which character to extract; based upon the index number of the string.</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">char extr;
String s1;
int ix;
extr = s1.charAt(ix);</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 This extracts the character with the index number ix, remember that the index number starts at 0 for the first character. The character would be saved in the variable extr.<br />
<br />
<br />
<div style="text-align: center;"><b>Comparing Contents</b></div>You can compare strings in couple of different ways. <br />
<br />
<b>The way that you will most often use is to compare the contents of the string.</b> You are able to do that using the following method.<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">String s1, s2;
if( s1.equals( s2 ) )
    System.out.println(&quot;Same string contents&quot;);</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <b>The other way is to compare the addresses that are stored in the variable itself.</b> This is a lot less common, and mainly used in the mistaken idea that it will compare the contents of the string. To compare storage locations of strings use the following method.<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">String s1, s2;
if( s1 == s2 )
    System.out.println(&quot;Same Addresses&quot;);</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <b>Another way that you can compare strings is by their alphabetic order.</b> This type or comparison sorts the strings from A-Z. This is done utilizing the following method.<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">String s1, s2;
int compare;
compare = s1.compareTo( s2 );
if( compare &lt; 0 )
    System.out.println(&quot;s1 is less than s2&quot;);
else if( compare &gt; 0 )
    System.out.println(&quot;s2 is less than s1&quot;);
else //compares for s1 == s2
    System.out.println(&quot;s1 is the same as s2&quot;);</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <br />
<div style="text-align: center;"><b>Converting Case</b></div><br />
<b>Another thing that you are able to do with strings is to convert their case.</b> You can covert all the characters to uppercase, or convert all the characters to lowercase. This is done using the following method.<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">String s1, s2, s3;
s2 = s1.toUpperCase();
s3 = s1.toLowerCase();</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 This does not change the string that is stored at the memory location s1; rather it makes two new strings and creates two new storage locations. An independent copy that is all lowercase is stored at memory location s3, while an independent copy that is all uppercase is stored at memory location s2.<br />
<br />
<br />
<div style="text-align: center;"><b>Changing a String</b></div><br />
<b>You can add to a String using the '+=' format.</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">String s1 = &quot;Hello&quot;;
s1 += &quot; World&quot;;</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <b>You can also replace the entire String using the '=' format.</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">String s1 = &quot;Hello&quot;;
s1 = &quot;Hello World&quot;;</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 </blockquote>

]]></content:encoded>
			<dc:creator>penguinCoder</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/penguincoder/1561-string-cheat-sheet.html</guid>
		</item>
		<item>
			<title>Class and Method Terminology Cheat Sheet</title>
			<link>http://www.java-forums.org/blogs/penguincoder/1560-class-method-terminology-cheat-sheet.html</link>
			<pubDate>Wed, 17 Oct 2012 20:45:58 GMT</pubDate>
			<description>*Class Body* - the area between the braces, that contains all the code. 
 
*Constructors* - used for initializing new objects 
 
*Declarations* -...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore"><b>Class Body</b> - the area between the braces, that contains all the code.<br />
<br />
<b>Constructors</b> - used for initializing new objects<br />
<br />
<b>Declarations</b> - fields that provide the state of the class and its objects<br />
<br />
<b>Methods</b> - implement the behaviour of the class and its objects<br />
<br />
<b>Fields</b> - member variables in a class<br />
<br />
<b>Local Variables</b> - variables in a method or a block of code<br />
<br />
<b>Parameters</b> - is the list of variables in a method declaration<br />
<br />
<b>Arguments</b> - are the actual values that are passe in when the method is invoked<br />
<br />
<b>Access Modifiers</b> - is the left most modifier in a field declaration, and lets the user control what other classes have access to its value<br />
  Public - the field is accessible from all classes<br />
  Private - the field is accessible from only within its own class<br />
<br />
<b>Object Declaration</b> - associate a variable name with an object type.  Example: ClassName classObject;<br />
<br />
<b>Object Instantiation</b> - The keyword 'new' is a Java operator that creates a new object<br />
<br />
<b>Object Initialization</b> - follows the keyword 'new', which is a call to a constructor, which initializes the new object.  Example: new ClassName( 12, 13 );<br />
<br />
<b>Object Creation</b> - is a combination of the Declaration, Instantiation, and the Initialization.  Example: ClassName classObject = new ClassName( 12, 13 );</blockquote>

]]></content:encoded>
			<dc:creator>penguinCoder</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/penguincoder/1560-class-method-terminology-cheat-sheet.html</guid>
		</item>
		<item>
			<title>Class and Method Cheat Sheet</title>
			<link>http://www.java-forums.org/blogs/penguincoder/1559-class-method-cheat-sheet.html</link>
			<pubDate>Wed, 17 Oct 2012 20:42:09 GMT</pubDate>
			<description><![CDATA[*Declaring a Class* 
<div class="bbcode_container"> 
	<div class="bbcode_description">Java Code: </div> 
 
	<pre class="brush: java">class ClassName{...]]></description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore"><b>Declaring a Class</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">class ClassName{
  ...code...
}</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <br />
<b>Declaring a Class with Parent</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">class ClassName extends parentClassName{
  ...code...
}</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <br />
<b>Declaring a class with Interface</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">class ClassName implements interface1, interface2, interface3{
   ...code...
}</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <br />
<b>Declaring a Class with Fields</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">class ClassName{
  public &#91;type&#93; publicFieldName;
  private &#91;type&#93; privateFieldName;
  private static &#91;type&#93; staticPrivateFieldName;
  ...code...
}</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <br />
<b>Declaring a Private Class</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">private Class className{
  ...code...
}</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <br />
<b>Declaring a Method</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">public &#91;returnType&#93; methodName(){
  ...code...
}</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <br />
<b>Declaring a Method that does Not Return Anything</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">public void methodName(){
  ...code...
}</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <br />
<b>Declaring a Method with Parameters</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">public &#91;returnType&#93; methodName( &#91;type&#93; paramVar1, &#91;type&#93; paramVar2){
   ...code...
}</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <br />
<b>Declaring a Method with an Array in Parameters</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">public &#91;returnType&#93; methodName( &#91;type&#93;&#91;&#93; arrayName){
  ...code...
}</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <br />
<b>Declaring a Private Method</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">private &#91;returnType&#93; methodName(){
  ...code...
}</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <br />
<b>Declaring a Method with varargs</b><br />
Varargs is a feature that allows an undefined amount of parameters to be passed in, and used like an array.  It must be the last item in the parameter list.<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">public &#91;returnType&#93; methodName( &#91;type&#93;... varName ){
   ...code...
}</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <br />
<b>Method Signature</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">methodName( &#91;type&#93; paramVar1, &#91;type&#93; paramVar2 )</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <br />
<b>Method Overloading</b><br />
Java is able to distinguish between several methods with the same name based upon what is called in the parameter list.  However, it does NOT differentiate different methods based on its return type.<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">public class ClassName{
  ...fields...

  public void methodName( String s ){
    ...code...
  }
  public void methodName( int i ){
    ...code...
  }
  public void methodName( double d ){
    ...code...
  }
  public void methodName( boolean b ){
    ...code...
  }
  public void methodName( String s, int i){
    ...code...
  }
}</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <br />
<b>Adding a Constructor to a Class</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">public class ClassName{
  ...fields...

  public ClassName( &#91;type&#93; paramVar1, &#91;type&#93; paramVar2 ){
    fieldName1 = paramVar1;
    fieldName2 = paramVar2;
  }
}</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <br />
<b>Adding Multiple Constructors to a Class</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">
public class ClassName{
  ...fields...

  public ClassName(){
    fieldName1 = 0;
    fieldName2 = 0;
  }

  public ClassName( &#91;type&#93; paramVar1, &#91;type&#93; paramVar2 ){
    fieldName1 = paramVar1;
    fieldName2 = paramVar2;
  }
}</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <br />
<b>Creating a Constructor with Parameters that Shadow Fields</b><br />
Shadowing fields makes your code difficult to read, and is conventionally only used within Constructors or Methods that set a particular Field.<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">public class ClassName{
  private &#91;type&#93; fieldName1;
  private &#91;type&#93; fieldName2;

  public ClassName( &#91;type&#93; fieldName1, &#91;type&#93; fieldName2 ){
    this.fieldName1 = fieldName1;
    this.fieldName2 = fieldName2;
  }
}</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <br />
<b>Calling the Constructor, with Arguments, to Initialize Object</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">ClassName classObject = new ClassName( &#91;value&#93; , &#91;value&#93; );</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <br />
<b>Calling the Constructor, with No Arguments, to Initialize Object</b><br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">ClassName classObject = new ClassName();</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 </blockquote>

]]></content:encoded>
			<dc:creator>penguinCoder</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/penguincoder/1559-class-method-cheat-sheet.html</guid>
		</item>
		<item>
			<title>Some Basic Technical Terminolgy Cheat Sheet</title>
			<link>http://www.java-forums.org/blogs/penguincoder/1558-some-basic-technical-terminolgy-cheat-sheet.html</link>
			<pubDate>Wed, 10 Oct 2012 02:08:56 GMT</pubDate>
			<description>Well I just got out of class, and I thought I would do a brain dump of some of the terminology that is utilized in Programming and Computer Science. ...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">Well I just got out of class, and I thought I would do a brain dump of some of the terminology that is utilized in Programming and Computer Science.  This is going to be in more human readable format then most places I have found on the Internet.<br />
<br />
<div style="text-align: center;"><b>Abstract Algorithm Analysis</b></div><b>What is O(N)?</b><br />
Big O of N, and it is commonly pronounced, is when the run-time of an algorithm is approximately proportional to the size of the data (N), when there are large amounts of data; in the worst case scenario.<br />
<br />
<b>What happens when run-time is doubled?</b><br />
<b>O(1) </b>- Nothing changes<br />
<b>O(logN)</b> - Increases by a constant<br />
<b>O(N)</b> - Doubles<br />
<b>O(NlogN)</b> - Increases by a little more than double<br />
<b>O(N^2)</b> - Quadruples<br />
<b>O(2^N)</b> - Squares<br />
<br />
<br />
<div style="text-align: center;"><b>Traditional Procedural Programming VS Object-Orientated Programming</b></div><b>Tradition Procedural Programming</b><br />
<ul><li style="">Also called Process-Orientated or Task-Orientated Programming</li><li style="">Focuses on a specific application, and the sequence of steps to accomplish a given task</li><li style="">The code can be optimized for the needs of that application, so it may be more efficient in time and space during run-time</li><li style="">Very difficult to reuse due to it being customized</li></ul><br />
<br />
<b>Object-Orientated Programming</b><br />
<ul><li style="">Data-Orientated</li><li style="">Focuses on development of general purpose data management tools to support all possible related applications</li><li style="">Focuses on code reuse</li><li style="">Initial development may take longer, but the ability to reuse existing tools will make future developments much quicker</li><li style="">The generality of these tools may cause them to be less efficient at run-time</li></ul><br />
<br />
<br />
<div style="text-align: center;"><b>Record VS Object</b></div>A <b>record</b> contains just data, and has no control over its access and manipulation.<br />
An <b>object</b> contains both data and the code to manipulate that data.  Data can be declared private, using the keyword 'private', restricting access to this data to public methods inside of the class; this is called Data Hiding.  An object also has a constructor method, which combines the task of storage allocation and initialization into one inseperable operation.  It also allows for the separation between 'interface' and 'implementation'.<br />
<br />
<br />
<div style="text-align: center;"><b>Instance VS Class</b></div>The best analogy of these two are cookies.  The class would be considered the cookie cutter, where the instance would be considered the actual cookie.<br />
An <b>instance</b> is one specific example of an object.  It has both values and storage allocated to it.<br />
A <b>class</b> is a template/model for an object.  A class defines a new variable type, and therefore does not have either a value or storage allocated to it.  It is initialized using the keyword 'new'.<br />
<br />
<br />
<div style="text-align: center;"><b>Static Data Members VS Non-Static Data Members</b></div>A <b>static data member</b> is shared by all members of that class.  It is allocated storage in the Static Space, alongside the code.  The lifetime of a static data member is throughout the entire program's execution.  It can be accessed inside or outside of a method, through the use of the class name.<br />
A <b>non-static data member</b>, also called an instance variable, is unique for each instance.  It is allocated storage in the Heap Space, and the lifetime of a non-static variable is from the initialization, use of the keyword 'new', to the point when there are no more references to the instance that it is associated with; and the garbage collector has been run.  It cannot be accessed through static member functions.<br />
They <b>both</b> are defined inside of a class, but outside of any method.  They also both have the same visibility, although it is dependent upon their privacy qualifier.  If they are defined using the keyword 'public', they can be accessed from anywhere.  If they are defined using the keyword 'private', they can only be accessed by methods in the same class.<br />
<br />
<br />
<div style="text-align: center;"><b>Virtual Memory</b></div><b>Static Space</b><br />
Contains the program code, along with any data members and functions.<br />
<b>Stack Space</b><br />
Contains local variables.  These locations may be used by one function, and later be reused by another function.<br />
<b>Heap Space</b><br />
Contains dynamically allocated storage; things that are declared using the keyword 'new'.  Locations are assigned by the run-time memory management system, as requested during execution; then reclaimed during garbage collection if no longer used.<br />
<br />
<br />
<div style="text-align: center;"><b>Local Variables</b></div><b>Local variables</b> are defined inside of a method, and are only 'alive' while the method is being executed.  They are allocated storage when the method is executed, and they lose their storage as soon as the method exits.  Their visibility is only the containing block, bound by the closest pair of curly braces ({}).</blockquote>

]]></content:encoded>
			<dc:creator>penguinCoder</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/penguincoder/1558-some-basic-technical-terminolgy-cheat-sheet.html</guid>
		</item>
		<item>
			<title>problem with shopping cart</title>
			<link>http://www.java-forums.org/blogs/blustar-angel/1557-problem-shopping-cart.html</link>
			<pubDate>Wed, 29 Aug 2012 12:15:32 GMT</pubDate>
			<description>how do i increase the quatity of an item when it is added again and again into my shopping cart table.there is only a button add to cart.there is no...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">how do i increase the quatity of an item when it is added again and again into my shopping cart table.there is only a button add to cart.there is no textfeild for quantitiy.<br />
the code as of now i have retreives the items from database and add it into the shipping cart table.  if i clik on it again and again the same item wil be shown again and again.<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java"> DefaultTableModel model = (DefaultTableModel) 
tbl1.getModel();
            DefaultTableModel tm = (DefaultTableModel) 
tbl2.getModel();
            int a = tbl1.getSelectedRow();
            if (a == 0) {
                
                try {
                    Class.forName(&quot;java.sql.Driver&quot;);
                    Connection con = DriverManager.getConnection(&quot;jdbc:mysql://localhost:3306/album&quot;, &quot;root&quot;, &quot;123&quot;);
                    Statement stm = con.createStatement();
                    String sql = &quot;select ALBUMNAME,PRICE FROM albums WHERE ALBUMNAME='twilight' ;&quot;;
                    ResultSet res = stm.executeQuery(sql);
                    while (res.next()) {
                        String ALBUMNAME = res.getString(&quot;ALBUMNAME&quot;);
                        int PRICE = res.getInt (&quot;PRICE&quot;);

                        tm.addRow(new Object&#91;&#93;{ALBUMNAME, PRICE});
                    }
                    res.close();
                    con.close();
                    stm.close();
                    


                } catch (Exception e) {
                    JOptionPane.showMessageDialog(null, &quot;error in connectivity&quot;);
                }</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 </blockquote>

]]></content:encoded>
			<dc:creator>blustar angel</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/blustar-angel/1557-problem-shopping-cart.html</guid>
		</item>
		<item>
			<title>java (7) equivalent of .Net timespan</title>
			<link>http://www.java-forums.org/blogs/paul/1556-java-7-equivalent-net-timespan.html</link>
			<pubDate>Sat, 28 Jul 2012 05:03:11 GMT</pubDate>
			<description>---Quote (Originally by .paul.)--- 
i used Dates in this particular case, as they were better suited to the application. 
 
but i also created a java...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore"><div class="bbcode_container">
	<div class="bbcode_quote">
		<div class="quote_container">
			<div class="bbcode_quote_container"></div>
			
				<div class="bbcode_postedby">
					<img src="http://www.java-forums.org/images/misc/quote_icon.png" alt="Quote" /> Originally Posted by <strong>.paul.</strong>
					<a href="showthread.php?p=295367#post295367" rel="nofollow"><img class="inlineimg" src="http://www.java-forums.org/images/buttons/viewpost-right.png" alt="View Post" /></a>
				</div>
				<div class="message">i used Dates in this particular case, as they were better suited to the application.<br />
<br />
but i also created a java TimeSpan class, similar to the .Net Framework TimeSpan class:<br />
<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">package javaTimeSpans;

/**
 *
 * @author Paul
 */
public class TimeSpan {
    
    private int _days;
    private int _hours;
    private int _minutes;
    private int _seconds;
    
    public int Days(){
        return this._days;
    }
    public void SetDays(int d){
        this._days = d;
    }
    
    public int Hours(){
        return this._hours;
    }
    public void SetHours(int h){
        this._hours = h;
    }
    
    public int Minutes(){
        return this._minutes;
    }
    public void SetMinutes(int m){
        this._minutes = m;
    }
    
    public int Seconds(){
        return this._seconds;
    }
    public void SetSeconds(int s){
        this._seconds = s;
    }
    
    public TimeSpan(int d, int h, int m, int s){
        this._days = d;
        this._hours = h;
        this._minutes = m;
        this._seconds = s;
    }
    
    public TimeSpan(int h, int m, int s){
        this._days = 0;
        this._hours = h;
        this._minutes = m;
        this._seconds = s;
    }
    
    public Boolean Equals(TimeSpan ts){
        return this.Days() == ts.Days() &amp;&amp; this.Hours() == ts.Hours() &amp;&amp; this.Minutes() == ts.Minutes() &amp;&amp; this.Seconds() == ts.Seconds();
    }
    
    public TimeSpan Add(TimeSpan ts){
        int s = this.Seconds() + ts.Seconds();
        int m = this.Minutes() + ts.Minutes();
        int h = this.Hours() + ts.Hours();
        int d = this.Days() + ts.Days();
        
        if(s &gt; 59){
            s -= 60;
            m += 1;
        }
        if(m &gt; 59){
            m -= 60;
            h += 1;
        }
        if(h &gt; 23){
            h -= 24;
            d += 1;
        }
        
        return new TimeSpan(d,h,m,s);
        
    }
    
    public TimeSpan Subtract(TimeSpan ts){
        int s1 = this.Seconds();
        int m1 = this.Minutes() * 60;
        int h1 = this.Hours() * 60 * 60;
        int d1 = this.Days() * 24 * 60 * 60;
        
        int s2 = ts.Seconds();
        int m2 = ts.Minutes() * 60;
        int h2 = ts.Hours() * 60 * 60;
        int d2 = ts.Days() * 24 * 60 * 60;
        
        int sd = (s1+m1+h1+d1) - (s2+m2+h2+d2);
        
        int d = sd / (int)(24 * 60 * 60);
        sd -= (d * (24 * 60 * 60));
        int h = sd / (int)(60 * 60);
        sd -= (h * (60 * 60));
        int m = sd / 60;
        int s = sd - (m * 60);
        
        return new TimeSpan(d,h,m,s); 
        
    }
    
    public int TotalHours() {
        return (this.Days() * 24) + this.Hours();
    }
    
    public int TotalMinutes() {
        return (((this.Days() * 24) + this.Hours()) * 60) + this.Minutes();
    }
    
    public int TotalSeconds() {
        return (((((this.Days() * 24) + this.Hours()) * 60) + this.Minutes()) * 60) + this.Seconds();
    }
    
    @Override public String toString() {
        if(this.Days() != 0){
            return String.format(&quot;%d:%02d:%02d:%02d&quot;, this.Days(),this.Hours(),this.Minutes(),this.Seconds());
        }
        else {
            return String.format(&quot;%02d:%02d:%02d&quot;, this.Hours(),this.Minutes(),this.Seconds());
        }
    }
    
}</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div></div>
			
		</div>
	</div>
</div></blockquote>

]]></content:encoded>
			<dc:creator>.paul.</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/paul/1556-java-7-equivalent-net-timespan.html</guid>
		</item>
		<item>
			<title>xml encoding problem.</title>
			<link>http://www.java-forums.org/blogs/sbutt/1554-xml-encoding-problem.html</link>
			<pubDate>Wed, 11 Jul 2012 08:52:52 GMT</pubDate>
			<description>Hi All, 
       I am trying to embedd an xml response string as CData inside an XML tree. The main XML tree is not in my control to create or change....</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">Hi All,<br />
       I am trying to embedd an xml response string as CData inside an XML tree. The main XML tree is not in my control to create or change. I just have a class object where i am just setting the content as String, where the string is my xml.<br />
<br />
The problem is when the mail xml tree appears, the content of my xml ( RawProfile ) are not properly encoded.<br />
<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">
&lt;ns5:PotsdamCache xmlns:ns2=&quot;http://schemas.xmlsoap.org/ws/2002/12/secext&quot; xmlns:ns3=&quot;http://www.opentravel.org/OTA/2003/05&quot; xmlns:ns4=&quot;http://www.opentravel.org/OTA/2002/11&quot; xmlns:ns5=&quot;http://www.PotsdamCache.com&quot;&gt;
			&lt;ns5:Content&gt;&amp;lt;!&#91;CDATA&#91; &amp; l t ; RawProfile &amp; g t ; &amp; l t ; ROWSET type = &amp;quot;AllLinkedParents&amp;quot;&amp; g t ; &amp; l t ; /ROWSET&amp;gt;&amp;lt;ROWSET type = &amp;quot;AllParents&amp;quot;&amp;gt;&amp;lt;ROWSET type = &amp;quot;organization&amp;quot;&amp;gt;&amp;lt;ROW type = &amp;quot;Raw&amp;quot;&amp;gt;PotsdamInstanceReference &#91;id=546565, type=organization, code=6565, name=KID for BE Requests, parentId=0, linkedParentIds=null&#93;&amp;lt;/ROW&amp;gt;&amp;lt;ROW type = &amp;quot;Name&amp;quot;&amp;gt;KID for BE Requests&amp;lt;/ROW&amp;gt;&amp;lt;ROW type = &amp;quot;Code&amp;quot;&amp;gt;1006565004&amp;lt;/ROW&amp;gt;&amp;lt;ROW type = &amp;quot;Id&amp;quot;&amp;gt;6565&amp;lt;/ROW&amp;gt;&amp;lt;ROW type = &amp;quot;ParentId&amp;quot;&amp;gt;0&amp;lt;/ROW&amp;gt;&amp;lt;/ROWSET&amp;gt;&amp;lt;ROWSET...&amp;lt;/RawProfile&amp;gt;&#93;&#93;&amp;gt;&lt;/ns5:Content&gt;&lt;/ns5:PotsdamCache&gt;</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 You might not see the encode problem above, since this editor handles it, but i hope you got my point. I ma getting these &amp; l t ; &amp; g t ; signs.<br />
<br />
<br />
I am simply doing the following<br />
<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">potsdamCacheRS.setContent(buildRawProfile(userInstance));</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 where my buildRawProfile method returns a string of my xml ...&quot;&lt;![CDATA[&lt;RawProfile&gt;&quot;.....&quot;&lt;/RawProfile&gt;]]&gt;&quot;.<br />
<br />
<br />
I also tried another aproach:<br />
<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">
  Document doc = parseRawProfile(buildRawProfile(userInstance), false);

	// Add a CDATA section to the root element
	Element element = doc.getDocumentElement();
	CDATASection cdata = doc.createCDATASection(buildRawProfile(userInstance));
	element.appendChild(cdata);

...

// Parses an XML file and returns a DOM document.
  // If validating is true, the contents is validated against the DTD
  // specified in the file.
  public Document parseRawProfile(String rawProfile, boolean validating) {
      try {
          // Create a builder factory
          DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
          factory.setValidating(validating);

          // Create the builder and parse the file
          Document doc = factory.newDocumentBuilder().parse(rawProfile);
          return doc;
      } catch (SAXException e) {
          // A parsing error occurred; the xml input is not valid
    	  log.debug(&quot; A parsing error occurred; the xml input is not valid &quot;);
      } catch (ParserConfigurationException e) {
    	  log.debug(&quot; A parsing configuration error occurred; the xml input is not valid &quot;);
      } catch (IOException e) {
    	  log.debug(&quot; A parsing IOException error occurred; the xml input is not valid &quot;);
      }
      return null;
  }</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <br />
But then got this error: 	<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">		&lt;faultstring&gt;javax.ejb.EJBTransactionRolledbackException: org.apache.xerces.jaxp.DocumentBuilderFactoryImpl cannot be cast to javax.xml.parsers.DocumentBuilderFactory&lt;/faultstring&gt;</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 <br />
The last approach, i didn't like so may be if someone could give a simple solution to this encoding problem.<br />
<br />
Thanks.</blockquote>

]]></content:encoded>
			<dc:creator>sbutt</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/sbutt/1554-xml-encoding-problem.html</guid>
		</item>
		<item>
			<title>Architecture of Web Service</title>
			<link>http://www.java-forums.org/blogs/web-service/1553-architecture-web-service.html</link>
			<pubDate>Sat, 07 Jul 2012 17:43:09 GMT</pubDate>
			<description>Following diagram explains the architecture of the web servers. 
 
Attachment 3939 (http://www.java-forums.org/attachment.php?attachmentid=3939) 
...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">Following diagram explains the architecture of the web servers.<br />
<br />
<div style="text-align: center;"><img src="http://www.java-forums.org/attachment.php?attachmentid=3939&amp;d=1341682915" border="0" alt="Name:  1.jpg
Views: 5689
Size:  29.1 KB" class="thumbnail" style="float:CONFIG" /></div><br />
<b><div style="text-align: center;">Web Service Architecture</div></b><br />
<br />
<b>	Web Service Discovery: </b>All the web services are discovered with the help of this part by meeting certain requirements and passing filters.  The UDDI which stands for Universal Description, Discovery and Integration handles this part of web services.<br />
<br />
<b>	Web Service Description:</b> All the web services are self describing which is most important and interesting feature. A web service can be described once it is located and it will describe about its operations. This part is handled by the Web Services Description Language (WSDL).<br />
<br />
<b>	Web Service Invocation:</b> The message handling between the web services and calling methods of a web service is called web service invocation. SOAP protocol is used to communicate with a web service.<br />
<br />
<b>	Web Service Transport:</b> The entire message transmission between client and server must be transmitted by some mean. The HTTP protocol is used to do this message transmission.</blockquote>

]]></content:encoded>
			<dc:creator>Web Service</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/web-service/1553-architecture-web-service.html</guid>
		</item>
		<item>
			<title>SOAP - Envelope Element</title>
			<link>http://www.java-forums.org/blogs/web-service/1552-soap-envelope-element.html</link>
			<pubDate>Sat, 07 Jul 2012 17:40:49 GMT</pubDate>
			<description>The end and the start of the message are indicated by SOAP envelope. The receiver will be informed of the complete message arrival.  When a message...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">The end and the start of the message are indicated by SOAP envelope. The receiver will be informed of the complete message arrival.  When a message is received and processed, it will be informed by the SOAP envelope. So it solved the major problem of informing message processing. So in other words we can say that is a packaging method.<br />
<br />
Following points will explain it in more detail:<br />
<br />
<ul><li style="">A root element is the base of SOAP envelop message and it is contained by all the messages.</li><li style="">Only single Body element must be part of the Envelope element.</li><li style="">Every SOAP message must contain the Envelope element.</li><li style="">There should be only one Header element in the Envelope and it should be before the body part of Envelope as a first child.</li><li style="">If the SOAP version is changed, the envelope must change.</li><li style="">The ENV namespace is used to specify namespace for SOAP envelope.</li><li style="">The Envelopeelement is used to specify the SOAP envelope.</li><li style="">The optionalencodingStyle element and namespace name are used to declare SOAP encoding.</li><li style="">The v1.1 and v1.2 messages are not compatible with each other and it will generate a fault on message.</li></ul></blockquote>

]]></content:encoded>
			<dc:creator>Web Service</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/web-service/1552-soap-envelope-element.html</guid>
		</item>
		<item>
			<title>SOAP Introduction</title>
			<link>http://www.java-forums.org/blogs/web-service/1551-soap-introduction.html</link>
			<pubDate>Sat, 07 Jul 2012 17:39:49 GMT</pubDate>
			<description>To exchange messages and information between multiple computers, XML based protocol is used which is called SOAP. SOAP is XML based protocol so you...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">To exchange messages and information between multiple computers, XML based protocol is used which is called SOAP. SOAP is XML based protocol so you can say that it is the XML specification application.<br />
<br />
Following rules or statements are considered as true for the SOAP.<br />
<br />
	It is a protocol for communication.<br />
	SOAP stands for Simple Object Access Protocol.<br />
	It is designed to use internet for all its communication.<br />
	It has the facility to use HTTP for sending XML messaging.<br />
	It handles data transportation of web services.<br />
	A remote procedure may be called using this protocol.<br />
	It can also be used to send documents.<br />
	It can also be used for message broadcasting.<br />
	It is independent of language.<br />
	It is independent of platform.<br />
	It is based on XML to send and get information and define how it will be achieved.<br />
<br />
SOAP is used in:<br />
<br />
	Different message systems.<br />
	Transport protocols<br />
	Remote procedure calls.<br />
<br />
The major focus of SOAP is on the remote procedure calls using HTTP. It helps different applications to connect and method calling remotely.</blockquote>

]]></content:encoded>
			<dc:creator>Web Service</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/web-service/1551-soap-introduction.html</guid>
		</item>
		<item>
			<title>Log4J Support Objects</title>
			<link>http://www.java-forums.org/blogs/log4j/1550-log4j-support-objects.html</link>
			<pubDate>Sat, 07 Jul 2012 17:37:56 GMT</pubDate>
			<description>Following are the log4j framework important support objects which are critical in this framework. 
 
*	Level Object:* This object is used to define...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">Following are the log4j framework important support objects which are critical in this framework.<br />
<br />
<b>	Level Object:</b> This object is used to define priority of log information. Following log levels are defined in the log4j API:<br />
<div style="margin-left:40px">o	INFO<br />
o	DEBUG<br />
o	ERROR<br />
o	OFF<br />
o	FATAL<br />
o	WARN<br />
o	ALL</div><br />
<b>	Filet Object:</b> This object is used to filter and analyze the logging information. Based on the analysis and filter criteria, logging information is logged. Multiple filter objects are attached with the appended object. All these associated filter objects with the appender object must pass the log information so that it can be published. <br />
<br />
<b>	ObjectRenderer:</b> The logging framework gets different objects string representations using this ObjectRenderer object. The Laout objects used this ObjectRenderer object to arrange log information.<br />
<br />
<b>	LogManager:</b> The LogManager reads the configuration parameters at the startup from a class of file and manage loging framework.</blockquote>

]]></content:encoded>
			<dc:creator>Log4j</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/log4j/1550-log4j-support-objects.html</guid>
		</item>
		<item>
			<title>log4j - Core Objects</title>
			<link>http://www.java-forums.org/blogs/log4j/1549-log4j-core-objects.html</link>
			<pubDate>Sat, 07 Jul 2012 17:36:26 GMT</pubDate>
			<description>Following are the log4j framework important core objects which are important and play a critical role in this framework. 
 
*	Logger Object:* The...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">Following are the log4j framework important core objects which are important and play a critical role in this framework.<br />
<br />
<b>	Logger Object:</b> The Logger object is provided by the top Logger layer. All the information captured by this Logger Object is stored in a hierarchy and this is the main object responsible for collecting all information.<br />
<br />
<b>	Layout Object:</b> The Layout Object is responsible for formatting all the information in multiple styles. The Layout Objects helps the applender objects in publishing logs. The Layout Objects make the logging information in easy and understandable format.<br />
<br />
<b>	Appender Object:</b> The Appender Object is at the low lever and is used to publish logs. It is used to publish log information to following destinations:<br />
<div style="margin-left:40px">o	File<br />
o	Database<br />
o	Unix Syslog<br />
o	Console</div><br />
<div style="text-align: center;"><img src="http://www.java-forums.org/attachment.php?attachmentid=3938&amp;d=1341682567" border="0" alt="Name:  1.jpg
Views: 95
Size:  46.5 KB" class="thumbnail" style="float:CONFIG" /></div><b><div style="text-align: center;">log4j - Core Objects</div></b></blockquote>

]]></content:encoded>
			<dc:creator>Log4j</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/log4j/1549-log4j-core-objects.html</guid>
		</item>
		<item>
			<title>log4j  Introduction</title>
			<link>http://www.java-forums.org/blogs/log4j/1548-log4j-introduction.html</link>
			<pubDate>Sat, 07 Jul 2012 17:34:30 GMT</pubDate>
			<description>Log4J is a Java based API that provides a logging framework which is: 
 
	Fast 
	Reliable 
	Flexible 
 
The Apache software License provides the...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">Log4J is a Java based API that provides a logging framework which is:<br />
<br />
	Fast<br />
	Reliable<br />
	Flexible<br />
<br />
The Apache software License provides the Log4J distribution. It has been also ported to following different languages:<br />
<br />
	C++<br />
	C<br />
	C#<br />
	Python<br />
	Eiffel<br />
	Ruby<br />
<br />
Following are the core features and functionalities of Log4J Framework:<br />
<br />
	It is configurable at runtime using files.<br />
	It defines the log levels and priorities.<br />
	It supports logging to following:<br />
<div style="margin-left:40px">o	File<br />
o	Database<br />
o	Unix Syslog<br />
o	Console</div><br />
The Log4J Framework has following 3 major components:<br />
<br />
1.	Loggers: The logging information is collected by the loggers.<br />
2.	Appenders: They are responsible for publishing logs on the destinations as defined previously.<br />
3.	Layouts: They are used for log formatting.<br />
<br />
<br />
Following are the advantages of logging:<br />
<br />
	The software development considers the loggings as its integral part.<br />
	It supports fast debugging and tracking of issues.<br />
	It supports structured and maintainable information storage.<br />
<br />
Following are the disadvantages of logging:<br />
<br />
	Slow down the application processing in some cases.</blockquote>

]]></content:encoded>
			<dc:creator>Log4j</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/log4j/1548-log4j-introduction.html</guid>
		</item>
		<item>
			<title>What are the Major Servlets Tasks</title>
			<link>http://www.java-forums.org/blogs/jsp/1547-what-major-servlets-tasks.html</link>
			<pubDate>Sat, 07 Jul 2012 17:31:55 GMT</pubDate>
			<description>Following are the major servlets tasks: 
 
	The Servlet major task is to read client data that is explicitly sent. It may include: 
o	Data sent by a...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">Following are the major servlets tasks:<br />
<br />
	The Servlet major task is to read client data that is explicitly sent. It may include:<br />
<div style="margin-left:40px">o	Data sent by a web page in form of HTML form<br />
o	Data sent by an applet<br />
o	Data sent by some HTTP client</div><br />
	The Servlet major task is to read client data that is implicitly sent. It may include:<br />
<div style="margin-left:40px">o	Media types<br />
o	Cookies<br />
o	Different compression</div><br />
	The servlet is responsible for data processing and results are produced on processed data. These processes may include:<br />
<div style="margin-left:40px">o	RMI execution<br />
o	Database communication<br />
o	Calling a web service<br />
o	Call a CORBA<br />
o	A direct response is computed</div><br />
	The servlet is responsilble for sending following type of explicit data to its clients:<br />
<div style="margin-left:40px">o	Binary  GIF images<br />
o	Text  HTML/XML<br />
o	Excel</div><br />
	The servlet is responsible for sending responses to its clients. This process may include following:<br />
<div style="margin-left:40px">o	Type of document is informed to client.<br />
o	Caching parameters<br />
o	Cookies Handling</div></blockquote>

]]></content:encoded>
			<dc:creator>JSP</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/jsp/1547-what-major-servlets-tasks.html</guid>
		</item>
		<item>
			<title>Exception Handling in JSP</title>
			<link>http://www.java-forums.org/blogs/jsp/1546-exception-handling-jsp.html</link>
			<pubDate>Sat, 07 Jul 2012 17:30:40 GMT</pubDate>
			<description>There is always a probability of programming errors in the code while a programmer is coding a JSP page. Following are the major types of errors...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">There is always a probability of programming errors in the code while a programmer is coding a JSP page. Following are the major types of errors which may arise in a JSP code:<br />
<br />
	<b>Checked Exceptions:</b> The checked exception is an unforeseen error by the programmer of JSP code or it is a user error in the code. For example, you are opening a file which may not exisit or may have some issue will raise an exception. At the compile time, these checked exceptions cannot be ignored.<br />
<br />
	<b>Runtime Exceptions:</b> The runtime exceptions occur at the time of program execution and may be avoided by the programmer. As compred to checked exceptions, these exceptions are ignored or not caught by the compile while program is being compiled.<br />
<br />
	<b>Errors:</b> These are uncontroable issue which a user or program cannot handle either at compile time or runtime and they are totally different from exceptions. You usually cannot find the errors in your code like a stack overflow. Also compiler cannot trace these errors at compile time.</blockquote>

]]></content:encoded>
			<dc:creator>JSP</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/jsp/1546-exception-handling-jsp.html</guid>
		</item>
		<item>
			<title>Hits Counter in a JSP Page</title>
			<link>http://www.java-forums.org/blogs/jsp/1545-hits-counter-jsp-page.html</link>
			<pubDate>Sat, 07 Jul 2012 17:29:45 GMT</pubDate>
			<description>You have a website developed in JSP with different pages. The hit counter will help you the total number of users visit your any JSP page.  In most...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">You have a website developed in JSP with different pages. The hit counter will help you the total number of users visit your any JSP page.  In most cases, the hit counter is attached with index.jsp page. It is the main login page and most users will first visit this page before navigating to any other page on your application or website. <br />
<br />
The following methods are used to implement hit counter.  These methods are attached with you Application object.<br />
<br />
	setAttribute()<br />
	getAttribute()<br />
<br />
The Application object is available in a JSP page and the Application object is created at JSP page initialization. It is destroyed when jspDestroy() method is called at the end of JSP page execution. <br />
<br />
To set an attribute at application level, following piece of code is used:<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">application.setAttribute(String key, Object Value);</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 The above setAttribute() method can be used to set the hit counter value and it is also used to reset the counter. <br />
<br />
Following piece of code is used to read the value.<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">application.getAttribute(String Key);</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 Use the above 2 methods to read and increment the counter value whenever a user visit your JSP page.</blockquote>

]]></content:encoded>
			<dc:creator>JSP</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/jsp/1545-hits-counter-jsp-page.html</guid>
		</item>
		<item>
			<title>Session Tracking in a JSP Page</title>
			<link>http://www.java-forums.org/blogs/jsp/1544-session-tracking-jsp-page.html</link>
			<pubDate>Sat, 07 Jul 2012 17:12:27 GMT</pubDate>
			<description>JSP communicates with the clients using stateless HTTP protocol. For each new request, following operations are performed: 
 
	A new connection is...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">JSP communicates with the clients using stateless HTTP protocol. For each new request, following operations are performed:<br />
<br />
	A new connection is opened with web server.<br />
	Server does not record client information.<br />
<br />
In this topic, we will focus on the different ways of handling and maintaining session information. Following are the 3 main ways for session maintaining.<br />
<br />
	<b>Cookies:</b> A cookies also known as session ID is assigned to a web client by the webserver for first request. Next time this session ID is used to recognize the client and maintain a session. There are cases in which web browser does not support cookies so it is not a recommended way of maintaining session.<br />
<br />
	<b>Hidden Fields:</b> Session can be maintained between client and webserver using hidden form fields. These hidden fields are automatically included with the form data and a unique value is communicated between client and server for session handling. This is a recommended approach for maintaining session but in case of hyper link click, it will not send the hidden fields so its hard to maintain session in such cases.<br />
<br />
	<b>URL Rewriting: </b>The session information can be appended at the end of of URL. It is a recommended way of maintaining sessions and it will also work for those browsers which do no support cookies.</blockquote>

]]></content:encoded>
			<dc:creator>JSP</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/jsp/1544-session-tracking-jsp-page.html</guid>
		</item>
		<item>
			<title>Form Processing in JSP</title>
			<link>http://www.java-forums.org/blogs/jsp/1543-form-processing-jsp.html</link>
			<pubDate>Sat, 07 Jul 2012 17:10:22 GMT</pubDate>
			<description>In a JSP progam, a programmer may have handled situations in which he sends information from browser to server and finally this information is...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">In a JSP progam, a programmer may have handled situations in which he sends information from browser to server and finally this information is communicated to backend business logic. Following two methods are used by the web browsers to send form data and information to web server.<br />
<br />
	<b>GET Method</b>: The encoded information is sent from browser to the server using this GET method. The information and page URL is separated using the ? character. Following is an example of GET method information passing.<br />
<a href="http://www.java-forums.com/test?key=value" target="_blank" rel="nofollow">http://www.java-forums.com/test?key=value</a><br />
To communicate information between client and web server, GET method is used as the default method. It will generate a long key value string and it will appear in your browser. This is not the recommended way of communication in case of sensitive information like passwords. Also this method has a limit of 1024 characters. <br />
<br />
	<b>POST Method:</b> The post method is consideres as a reliable and most recommended way of communication between client and web server. The POST method sends all the information and data as a separate message istead of sending it in the URL like GET Method. This message is parsed and used by the backend Java Program as it receives the message in a standard format. The data sent by this method is handled using getParameter() method.</blockquote>

]]></content:encoded>
			<dc:creator>JSP</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/jsp/1543-form-processing-jsp.html</guid>
		</item>
		<item>
			<title>Expressions in JSP</title>
			<link>http://www.java-forums.org/blogs/jsp/1542-expressions-jsp.html</link>
			<pubDate>Sat, 07 Jul 2012 17:09:18 GMT</pubDate>
			<description>The expression elements are supported by the JSP Page which: 
 
	Are based on scripting language 
	These expressions are evaluated. 
	These...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">The expression elements are supported by the JSP Page which:<br />
<br />
	Are based on scripting language<br />
	These expressions are evaluated.<br />
	These expressions are coverted to a String format<br />
	These are replaced with the expression elements in the JSP Page.<br />
<br />
The expression elements in a JSP page are finally converted to a string so you can use it anywhere in your JSP Page. These expression elements must be valid and follow the Java Language. There is only one restriction that you can terminate a line with seimicolon as we usually do in a Java statement.<br />
<br />
Following is an example of your JSP Expression Element:<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">&lt;%= your expression %&gt;</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 Also you can write the above expression element in following XML supported format:<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">&lt;jsp:expression&gt;
	Your expression
&lt;/jsp:expression&gt;</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 The below code represents and example of JSP Expression.<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">&lt;html&gt; 
&lt;body&gt;
   Date: &lt;%= (new java.util.Date()).toLocaleString()%&gt;
&lt;/body&gt; 
&lt;/html&gt;</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 </blockquote>

]]></content:encoded>
			<dc:creator>JSP</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/jsp/1542-expressions-jsp.html</guid>
		</item>
		<item>
			<title>How a JSP Page is processed?</title>
			<link>http://www.java-forums.org/blogs/jsp/1541-how-jsp-page-processed.html</link>
			<pubDate>Sat, 07 Jul 2012 17:07:19 GMT</pubDate>
			<description>In this topic, we will dicuss how a JSP Pages is created and processed by a web server. Following steps will explain it in more detail. 
 
	An HTTP...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">In this topic, we will dicuss how a JSP Pages is created and processed by a web server. Following steps will explain it in more detail.<br />
<br />
	An HTTP request is sent to the web server by your JSP Page.<br />
	The web server is responsible for receiving this JSP Page request and it will determine that its a JSP request so it will call the JSP engine. This process is done for the pages that have a .jsp extension.<br />
	The requested JSP page will be loaded from the disk and the JSP engine will convert it into a servlet. It is a simple conversion where:<br />
<div style="margin-left:40px">o	HTML text and converted and print statements are created using this HTML text.<br />
o	All the expressions are converted into proper Java code by the JSP engine.</div>	The generated servlet is finally compiled and converted into a class. This class is then forwarded to servlet engine.<br />
	Finally, this class is loaded and executed by the servlet engine. In the servlet execution process, HTML output is generated which is passed to web server.<br />
	The web server is responsible for sending this HTML output back to the web client.<br />
	As a last step, web browser handles the HTML output and renders it on the web page.<br />
<br />
<div style="text-align: center;"><img src="http://www.java-forums.org/attachment.php?attachmentid=3937&amp;d=1341680818" border="0" alt="Name:  1.jpg
Views: 668
Size:  30.1 KB" class="thumbnail" style="float:CONFIG" /></div><b><div style="text-align: center;">JSP Page Processing</div></b></blockquote>

]]></content:encoded>
			<dc:creator>JSP</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/jsp/1541-how-jsp-page-processed.html</guid>
		</item>
		<item>
			<title>What are the Advantages of JSP</title>
			<link>http://www.java-forums.org/blogs/jsp/1540-what-advantages-jsp.html</link>
			<pubDate>Sat, 07 Jul 2012 17:05:04 GMT</pubDate>
			<description>JSP offers the following advantages as compared to using other technologies in the market. 
 
	*JSP vs Active Server Pages:* The major benefit...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">JSP offers the following advantages as compared to using other technologies in the market.<br />
<br />
	<b>JSP vs Active Server Pages:</b> The major benefit offered by the JSP as compared to Active Server Pages is that it uses Java for expression writing which is more helpful, powerful and easy to use. Where as in Active Server Pages, you will need to use Visual Basic or any other Microsoft language. The second benefit offered by the JSP is that you can port it to any other operating system.<br />
<br />
	<b>JSP vs Pure Servlets:</b> In the servlets, you have to write the entire html in println statements which is hard to format, hard to understand and manage. JSP offers HTML writing in a simple file which is easy to manage.<br />
<br />
	<b>JSP vs Server Side Includes:</b> Server Side Includes is not designed for real programs and it is used for simple inclusions. So it does not support database connections and other functionality.<br />
<br />
	<b>JSP vs JavaScript<b></b>:</b> JavaScript is used to generate dynamic HTML content on the client end and for other scripting functionality. On the other hand it does not provide server interaction, database access, image processing etc.<br />
<br />
	<b>JSP vs Static HTML:</b> Static HTML is used to just render output on the browser and it does not provide dynamic information.</blockquote>

]]></content:encoded>
			<dc:creator>JSP</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/jsp/1540-what-advantages-jsp.html</guid>
		</item>
	</channel>
</rss>
