<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Video Training - Tutorials &#187; Java</title>
	<atom:link href="http://learnola.com/category/java/feed/" rel="self" type="application/rss+xml" />
	<link>http://learnola.com</link>
	<description>An insight into the world of Training Software</description>
	<lastBuildDate>Thu, 05 Jan 2012 08:00:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='learnola.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Video Training - Tutorials &#187; Java</title>
		<link>http://learnola.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://learnola.com/osd.xml" title="Video Training - Tutorials" />
	<atom:link rel='hub' href='http://learnola.com/?pushpress=hub'/>
		<item>
		<title>Programming Java Tutorial &#8211; input / output</title>
		<link>http://learnola.com/2009/01/23/programming-java-tutorial-input-output/</link>
		<comments>http://learnola.com/2009/01/23/programming-java-tutorial-input-output/#comments</comments>
		<pubDate>Fri, 23 Jan 2009 16:19:55 +0000</pubDate>
		<dc:creator>apexmedia</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Beginners Java Programming]]></category>
		<category><![CDATA[Java Programming]]></category>

		<guid isPermaLink="false">http://learnola.com/?p=445</guid>
		<description><![CDATA[We also have some excellent Beginners Programming Java tutorials that use high quality narrated videos and practical working files to teach the fundamentals of programming in Java Beginners Java Tutorial CD Java Tutorial &#8211; Input / Output The code below is based on Java 1.6 &#8211; some syntax may differ for previous versions. Receiving and [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=learnola.com&amp;blog=4742992&amp;post=445&amp;subd=apexmedia&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-full wp-image-12" title="case-disks1" src="http://apexmedia.files.wordpress.com/2008/09/case-disks1.jpg?w=455" alt=""   />We also have some excellent Beginners Programming Java tutorials that use high quality narrated videos and practical working files to teach the fundamentals of programming in Java <a href="http://www.hyperteach.com/products/java-6-video-cd.htm">Beginners Java Tutorial CD</a></p>
<p><a href="http://www.hyperteach.com/products/java-6-video-cd.htm"><img class="alignleft size-full wp-image-11" title="watch1" src="http://apexmedia.files.wordpress.com/2008/09/watch1.jpg?w=455" alt="watch1"   /></a></p>
<h2>Java Tutorial &#8211; Input / Output</h2>
<p><em>The code below is based on Java 1.6 &#8211; some syntax may differ for previous versions.</em></p>
<p>Receiving and sending data to and from an external source is something that you will likely have to do regularly as your programs develop. Java provides a number of classes and libraries to facilitate this process. In this tutorial we will concentrate on reading from and writing to external text files.</p>
<p>To send and receive data in Java, we use output and input &#8216;streams&#8217;. There are various resources within the Java language to interface with input and output streams in your programs, many of them suited to different types of programming tasks. This Java Tutorial will demonstrate a few of the more likely options for use within basic applications.</p>
<h3>Java &#8211; Reading from a file</h3>
<p>Create a new Java project in your IDE and add the following import statements at the top of your main class:</p>
<pre>
	//input/ output imports
import java.io.*;
import java.util.*;
</pre>
<p>These imports contain the classes that we will use for our I/O operations: the first of these classes will be FileReader and Scanner. In the first example, we will read the text from a text file into our program one line at a time. Enter the following code in your main method:</p>
<pre>//try block in case of IO exceptions
try
{
		//create filereader, passing filename
	String filename = "sometext.txt";
	FileReader fr = new FileReader(filename);
		//pass filereader to scanner
	Scanner scan = new Scanner(fr);
		//loop through the file content
	while(scan.hasNextLine())//check that there is more
	{	System.out.println(scan.nextLine());	}
		//close the input stream
	scan.close();
	fr.close();
}
	//an exception has been thrown
catch(IOException ioe)
{
		//output the details
	System.out.println(ioe);
	ioe.printStackTrace();
}
</pre>
<p>The code has to be included in try/catch blocks because, when your program relies on external input, there is always a risk of unforeseen error, such as problems with the external file. Placing your code within the try block allows your program to continue functioning when these problems occur, and provides you with the ability to decide what should happen if the I/O processing goes wrong. This is the function of the catch block, so you should place here whatever you want the program to do on encountering such an error, as this is where the code will jump to when that happens.</p>
<p>Before compiling your program, you will need to create the file for reading. Open a text editor (such as notepad/ notepad++) and enter the following:</p>
<pre>
Outside of a book
A dog is a man's best friend
Inside of a dog
It's too dark to read
</pre>
<p>Save your file with the name &#8216;sometext.txt&#8217; in the same directory within your workspace as the new project; for example, on Windows, if the project is called AProject and your workspace directory is C:\Workspace save the file in the C:\Workspace\AProject directory. If you look at the first line of code in the try block, you&#8217;ll see that the filename given is a relative URL, i.e. it does not have a drive listed as part of it; you can also use the class with an absolute URL if you need to.</p>
<p><em>NB: If you&#8217;re using Eclipse you can find out your workspace location by choosing Project &gt; Properties.</em></p>
<p>Now compile and run the program, you should see the contents of the file written a line at a time to the output console. What&#8217;s happening here is that the program is opening an input stream (according to the filename given) with the FileReader. The Scanner then processes the data from the stream, and can do this in a variety of ways, reading a line, a number or a byte at a time. Although our program merely outputs the data read in, once it&#8217;s in your program you can do whatever you need to with it, for example by assigning it to variables.</p>
<p>To demonstrate the purpose of the try and catch blocks, change the filename in the code so that it doesn&#8217;t match the actual file (e.g. String filename = &#8220;bla.txt&#8221;;) and run your program again. You&#8217;ll see the effect of the exception being thrown in your output console &#8211; this is because the program couldn&#8217;t find the file specified. (Remember to change the filename back afterwards.)</p>
<p>Using the Scanner, as above, makes text processing easier if you&#8217;re reading chunks of the text, however you can use the FileReader itself to read the file in a character at a time if this suits your needs. Processing data through the FileReader in this way is a little more complex, as the contents of the file are in the form of individual characters, including the newlines and end of file:</p>
<pre>
	//create FileReader
FileReader fRead = new FileReader(filename);
	//keep track of whether end of file reached
boolean end = false;
	//loop through file characters
while(!end)
{
		//read the next character (as an int)
	int ch = fRead.read();
		//-1 represents the end of file
	if(ch==-1)
		end=true;
	else
	{
			//write the character out
		char chr = (char)ch;
		System.out.print(chr);
	}
}
	//close the stream
fRead.close();
</pre>
<p>Run the program, it should have the same effect as the previous code.</p>
<h3>Writing to a file in Java</h3>
<p>The process for writing to files is similar, again, try and catch blocks are required and this time an output stream is opened. However, if your program cannot find the file specified to write to in the relevant directory, it will create it. If the file does exist the below methods will replace its contents. The first method writes to an output file using the FileWriter class, which can write a specified section of a string (in this case it should write &#8216;defg&#8217;); enter the following in your try block:</p>
<pre>//write out using FileWriter
FileWriter fw = new FileWriter("output1.txt");
	//write specified section of string
fw.write("abcdefghijkl", 3, 4);
fw.close();
</pre>
<p>Check your workspace project directory to see if the output1.txt has been created and written to.</p>
<p>The next example uses the PrintWriter class to write to the file; demonstrating two approaches to inserting newlines:</p>
<pre>//write out using PrintWriter
PrintWriter pw = new PrintWriter("output2.txt");
	//using println to insert newline at end
pw.println("Some text I'd like to write to a file");
pw.println("And some more");
	//use print - insert newline explicitly (\r\n)
pw.print("Yet more I'd like to write to a file\r\n" +
		"And more again.");
pw.close();
</pre>
<p>Again, check the appropriate directory for the output2.txt file; it should contain 4 lines of text.</p>
<p>Your programs will likely involve a range of different approaches to Input/Output depending on their particular requirements, so it is worth spending a little time familiarising yourself with the various options that Java provides.</p>
<br /> Tagged: Beginners Java Programming, Java, Java Programming <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/apexmedia.wordpress.com/445/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/apexmedia.wordpress.com/445/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/apexmedia.wordpress.com/445/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/apexmedia.wordpress.com/445/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/apexmedia.wordpress.com/445/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/apexmedia.wordpress.com/445/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/apexmedia.wordpress.com/445/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/apexmedia.wordpress.com/445/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/apexmedia.wordpress.com/445/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/apexmedia.wordpress.com/445/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/apexmedia.wordpress.com/445/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/apexmedia.wordpress.com/445/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/apexmedia.wordpress.com/445/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/apexmedia.wordpress.com/445/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=learnola.com&amp;blog=4742992&amp;post=445&amp;subd=apexmedia&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://learnola.com/2009/01/23/programming-java-tutorial-input-output/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2529d8f6ec74ee1afd5fd7dd213c6d5c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">apexmedia</media:title>
		</media:content>

		<media:content url="http://apexmedia.files.wordpress.com/2008/09/case-disks1.jpg" medium="image">
			<media:title type="html">case-disks1</media:title>
		</media:content>

		<media:content url="http://apexmedia.files.wordpress.com/2008/09/watch1.jpg" medium="image">
			<media:title type="html">watch1</media:title>
		</media:content>
	</item>
		<item>
		<title>Java Tutorial &#8211; Sorting and Searching Data</title>
		<link>http://learnola.com/2009/01/07/java-tutorial-sorting-and-searching-data/</link>
		<comments>http://learnola.com/2009/01/07/java-tutorial-sorting-and-searching-data/#comments</comments>
		<pubDate>Wed, 07 Jan 2009 18:32:32 +0000</pubDate>
		<dc:creator>apexmedia</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Java Programming]]></category>
		<category><![CDATA[Java Searching Data]]></category>
		<category><![CDATA[Java Tutorial]]></category>

		<guid isPermaLink="false">http://learnola.com/?p=428</guid>
		<description><![CDATA[We also have some excellent Beginners Programming Java tutorials that use high quality narrated videos and practical working files to teach the fundamentals of programming in Java Beginners Java Tutorial CD . Java Tutorial &#8211; Sorting, Searching and Recursion Once you start to use data structures in Java, you will inevitably encounter situations in which [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=learnola.com&amp;blog=4742992&amp;post=428&amp;subd=apexmedia&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-full wp-image-12" title="case-disks1" src="http://apexmedia.files.wordpress.com/2008/09/case-disks1.jpg?w=455" alt=""   />We also have some excellent Beginners Programming Java tutorials that use high quality narrated videos and practical working files to teach the fundamentals of programming in Java <a href="http://www.computer-training-software.com/java-6.htm">Beginners Java Tutorial CD</a></p>
<div style="border-bottom:#a3c159 2px dashed;">.</div>
<h2>Java Tutorial &#8211; Sorting, Searching and Recursion</h2>
<p>Once you start to use data structures in Java, you will inevitably encounter situations in which you need to sort or search through them. For the purposes of this beginners Java tutorial, we will use arrays to illustrate some basic sorting, searching and recursive algorithms.</p>
<p><em>An algorithm is a procedure, a series of steps that you define to solve a particular problem. In the examples below, our algorithms will be expressed in the Java code that we use in our programs.</em></p>
<h3>Recursion</h3>
<p>Some of the techniques we will be using rely on <strong>recursive</strong> processes, so let&#8217;s explore these first. A recursive method in your program is basically one that calls itself, i.e. within the method body, there will be a call to the method itself. Using recursive methods effectively can take a bit of practice, as your program can easily get caught in a loop, so you need to think the procedure in any such method through carefully.</p>
<p>To demonstrate a recursive function in action, let&#8217;s create a trivial example. Create a new Java project and enter the following in your main class, after the main method:</p>
<pre>//recursive method
public static int doSomething(int someNumber)
{
		//check the value of the input parameter
	if(someNumber&lt;=0)
		return someNumber;
	else
	{
			//decrement and call the method again
		someNumber--;
		System.out.println(someNumber);
		return(doSomething(someNumber));
	}
}</pre>
<p>Now call the new method within your main method:</p>
<pre>int result = doSomething(10);
System.out.println("done: " + result);</pre>
<p>All the program does is count down from the passed int value to zero. Experiment by changing the value of the int parameter passed to the method and observe what effect it has on the output printed to the console. The method manages to avoid getting stuck in a loop (caused by calling itself repeatedly) by having the conditional &#8216;if&#8217; statement.</p>
<p>This simple recursive method has much the same effect as a loop, but, as you&#8217;ll see, recursion can be particularly useful when you have a complex problem that is best solved in stages, each stage taking you a step closer to the solution by simplifying it. A necessary ingredient for recursive methods then is that you specify explicitly how the method should behave with the simplest input, and then with each iteration, you work towards this simplest case. In the example above, the simplest case is when the int parameter is less than or equal to zero.</p>
<p><em>Try not to worry if this seems an odd practice at first, once you start using sorting methods the recursive approach will become clearer.</em></p>
<h3>Sorting</h3>
<p>The main reason for keeping a collection of data in sorted order is that it is far easier to find items within the data and therefore maintain it effectively. Keeping the data in sorted order does, however, involve a certain amount of processing, particularly when adding or deleting items.</p>
<p>When we say, for example, that an array is in <strong>sorted order</strong>, we mean that the items within the array are arranged according to some understood ordering system. Sometimes this is intuitive, for example if the array contains numbers, sorted order will naturally comprise numbers stored according to ascending (or sometimes descending) numerical value. Similarly, if the array contains String values, sorted order will generally mean alphabetical order.</p>
<p>However, there are cases when sorted order will be less clear &#8211; imagine you have created your own class declaration for use within your program, and you wish to store objects of your class in the array. You will have to decide then what constitutes sorted order for these objects. In order to do this you have to think about comparing two objects of the same class. When you compare two objects of the class, it must be that case that either one is &#8216;greater&#8217; than the other, or they are &#8216;equal&#8217;. This is how your objects will be ordered, and to provide this in your own classes they will need to implement the Comparable interface, which means that your objects provide a compareTo method. Within this method you will need to decide how to measure the objects of your class against one another, for example, you might decide to use the value of some variable in the class.</p>
<p><em>Note: be careful when using the &#8216;equals&#8217; method on your objects also, as the default equals method inherited from the Class Object, actually tests the object references, i.e. it tests to see whether the two variable names are pointing to the same object. If you plan to use the equals method, you would be best to provide your own implementation of the method, overriding the default for this reason.</em></p>
<p>For the purposes of this Java tutorial, we will stick to simple types in order to illustrate the algorithms required.</p>
<h4>Selection Sort</h4>
<p>Selection sort works by continually finding the next smallest item in the collection and placing it at the front. Create a new program and enter the following code in your main method to create an array with some arbitrary data in it:</p>
<pre>	//array with unsorted int data
int [] myData = {3, 1, 9, 5, 7};</pre>
<p>Now we will use selection sort to arrange the items in the array in ascending numerical order. The selection sort technique is as follows:</p>
<ul>
<li>Within the section of data that is yet to be sorted (initially the whole structure), find the smallest item</li>
<li>Place this item at the first position (of the unsorted section), swapping it with any element that&#8217;s already there</li>
<li>The unsorted section now contains one less item (the item just deemed smallest and therefore moved)</li>
<li>Continue placing the smallest unsorted item in first position until all of the data has been sorted</li>
</ul>
<p>Enter the following code after declaring the array and compile your program, observing its output:</p>
<pre>	//loop through the array
for(int pos=0; pos&lt;myData.length-1; pos++)
{
		/* find and keep track of the smallest
		 * element's position
		 * -start at pos and look through the rest
		 * (pos is at the start of the unsorted section)
		 */
	int minIndex = pos;

		//loop through the unsorted section
	for(int next=pos+1; next&lt;myData.length; next++)
	{
		if(myData[minIndex]&gt;myData[next])
			minIndex=next;
	}

		//swap the item if necessary
	if(minIndex!=pos)
	{
			//keep track of the value currently at pos
		int temp = myData[pos];
			//copy the new smallest value into pos
		myData[pos] = myData[minIndex];
			//copy the swapped value into minIndex
		myData[minIndex] = temp;
	}

		//print the array for demonstration
	for(int p : myData)
	{	System.out.print(p);	}
	System.out.println();
}</pre>
<p>When you look at the program output, try to work through which items are being swapped with one another at each stage &#8211; experiment by changing the int values (or their order) in the array.</p>
<h4>Merge Sort</h4>
<p>A more efficient approach to sorting the contents of an array is Merge Sort, which uses a recursive algorithm. This rests on the idea that merging two already sorted arrays is a simpler problem than sorting all of the data in one unsorted array. The algorithm therefore sorts an unsorted array by continually dividing it into two parts and sorting each part, merging the results into a final sorted array.</p>
<p>Add the following method to your program (after the main method):</p>
<pre>/* mergeSort method sorts the data in a section of
	 * the array passed
	 * -parameters are the array containing the data to
	 *  be sorted, a temporary array for use with the
	 *  processing, and integers representing the start
	 *  and end positions of what data is to be sorted
	 *  within the array
	 */
public static void mergeSort(int[] dataArray, int[] tempArray,
							int start, int end)
{
		//array has been sorted
	if(start==end)
		return;
		//work towards sorted array by breaking the problem down
	else
	{
			//divide the data into two
		int center = (start+end)/2;
			//call the method on the first half
		mergeSort(dataArray, tempArray, start, center);
			//second half
		mergeSort(dataArray, tempArray, center+1, end);

			//merge the two halves into one sorted half
		int firstIndex = start;
		int secondIndex = center+1;
		int thirdIndex = start;

			//loop through both halves
		while(thirdIndex&lt;=end)
		{
				/* work through both halves
				 * inserting smallest item into
				 * the temp array each time
				 */
			if(secondIndex&gt;end ||
			(firstIndex&lt;=center &amp;&amp;
			dataArray[firstIndex]&lt;=dataArray[secondIndex]))
			{
				tempArray[thirdIndex]=dataArray[firstIndex];
				thirdIndex++;
				firstIndex++;
			}
			else
			{
				tempArray[thirdIndex]=dataArray[secondIndex];
				thirdIndex++;
				secondIndex++;
			}
		}
			//copy the temp contents into the main array
		for(int i=start; i&lt;=end; i++)
			dataArray[i]=tempArray[i];
	}
}</pre>
<p>Each time the method reaches the point of merging two halves, each half has already been sorted, since the mergeSort method has been first called on them, and on their subsections before they come to be merged, and so on. The method therefore solves the problem by repeatedly simplifying it and solving the simpler problems in turn. Now call the new method from your main method:</p>
<pre>	//array to sort
int[] someData = {4, 3, 7, 6, 2, 8, 5, 9, 1};
	//extra helper array
int[] extraArray = new int[someData.length];
	//call the mergesort method on the whole array
mergeSort(someData, extraArray, 0, someData.length-1);

	//print the sorted array for testing
for(int pr : someData)
{ System.out.print(pr); }</pre>
<p>Again, experiment by changing the values in the input array and observing the program output.</p>
<p>It can be difficult to get into the &#8216;recursive&#8217; way of thinking and certainly requires practice, but once you do you will tend to find that you identify problems that could benefit from a recursive solution fairly quickly. It can help when writing a recursive method if you start from the simplest case, then take care of the steps that work towards it each time the method executes (rather than starting from the most complex input, which is the first one to be executed, and can therefore seem an intuitive starting point).</p>
<h3>Searching</h3>
<p>You will often face the task of finding a particular element in a data structure for one reason or another. If your array data is unsorted, the only way to do this is to look through each of the elements in turn. This is known as <strong>linear search</strong> &#8211; enter the following code in your main method:</p>
<pre>//collection of arbitrary strings
String[] myStrings = {"potato", "carrot", "turnip",
		"onion", "leek", "courgette", "aubergine"};
	//find the index of 'leek'
int foundIndex=-1;
	//loop through the array
for(int veg=0; veg
	//binary search method
public static int binarySearch(String[] theData, String wanted)
{
		//-1 means item not found
	int foundIndex=-1;

		//keep track of both ends of searchable area
	int top = theData.length-1;
	int bottom = 0;

		//loop through, dividing searchable area each time
	while(bottom&lt;=top)
	{
			//look at middle element
		int middle = (top+bottom)/2;

			//compare middle element to item searched for
		int comp = theData[middle].compareTo(wanted);

			//middle is item searched for
		if(comp==0)
			return middle;

			/* if middle element is greater,
			 * wanted element must be in lower half
			 * and vice-versa, so we reduce the
			 * searchable area accordingly
			 */

		else if(comp&gt;0) //middle is greater
			top=middle-1;
		else //middle is lesser
			bottom=middle+1;

	}
		//finished searching
	return foundIndex;
}</pre>
<p>Now call the method within your main method:</p>
<pre>//array of sorted strings
String[] sortedStrings = {"aubergine", "carrot", "courgette",
		"leek", "onion", "potato", "turnip"};

	//call the method - returns -1 if item not found
int searchResult = binarySearch(sortedStrings, "potato");

System.out.println("found at index: "+searchResult);</pre>
<p>Experiment with the code by searching for different elements in the array &#8211; you can also check how many iterations of the loop are required each time by including a System.out.print statement within the while loop in your binarySearch method. It is generally a good practice to include such &#8216;trace statements&#8217; in your code, to check exactly what is happening at any stage in the program; it can be particularly helpful when debugging larger programs.</p>
<p>Although many of Java&#8217;s built-in datatypes provide sorting and searching methods, it can help with the efficiency of your own programs to think about the algorithms involved. Also, when you come to define your own data types, you may need to implement such methods yourself. There are numerous approaches to sorting and searching in Java, the examples above being only an introduction.</p>
<br /> Tagged: Java Programming, Java Searching Data, Java Tutorial <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/apexmedia.wordpress.com/428/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/apexmedia.wordpress.com/428/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/apexmedia.wordpress.com/428/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/apexmedia.wordpress.com/428/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/apexmedia.wordpress.com/428/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/apexmedia.wordpress.com/428/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/apexmedia.wordpress.com/428/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/apexmedia.wordpress.com/428/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/apexmedia.wordpress.com/428/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/apexmedia.wordpress.com/428/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/apexmedia.wordpress.com/428/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/apexmedia.wordpress.com/428/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/apexmedia.wordpress.com/428/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/apexmedia.wordpress.com/428/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=learnola.com&amp;blog=4742992&amp;post=428&amp;subd=apexmedia&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://learnola.com/2009/01/07/java-tutorial-sorting-and-searching-data/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2529d8f6ec74ee1afd5fd7dd213c6d5c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">apexmedia</media:title>
		</media:content>

		<media:content url="http://apexmedia.files.wordpress.com/2008/09/case-disks1.jpg" medium="image">
			<media:title type="html">case-disks1</media:title>
		</media:content>
	</item>
		<item>
		<title>Java Tutorial &#8211; Connect to MySQL Database</title>
		<link>http://learnola.com/2009/01/07/java-tutorial-connect-to-mysql-database/</link>
		<comments>http://learnola.com/2009/01/07/java-tutorial-connect-to-mysql-database/#comments</comments>
		<pubDate>Wed, 07 Jan 2009 18:06:13 +0000</pubDate>
		<dc:creator>apexmedia</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Beginners Java Tutorial]]></category>
		<category><![CDATA[Java Datebases]]></category>
		<category><![CDATA[MySQL and Java]]></category>

		<guid isPermaLink="false">http://learnola.com/?p=424</guid>
		<description><![CDATA[We also have some excellent Beginners Programming Java tutorials that use high quality narrated videos and practical working files to teach the fundamentals of programming in Java Beginners Java Training Videos &#8211; Programming . Java Tutorial &#8211; Database Programming This tutorial assumes knowledge of basic database concepts and MySQL. In this Java tutorial you will [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=learnola.com&amp;blog=4742992&amp;post=424&amp;subd=apexmedia&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-full wp-image-12" title="case-disks1" src="http://apexmedia.files.wordpress.com/2008/09/case-disks1.jpg?w=455" alt=""   />We also have some excellent Beginners Programming Java tutorials that use high quality narrated videos and practical working files to teach the fundamentals of programming in Java <a href="http://www.hyperteach.com/products/java-6-video-cd.htm">Beginners Java Training Videos &#8211; Programming</a></p>
<div style="border-bottom:#a3c159 2px dashed;">.</div>
<h2>Java Tutorial &#8211; Database Programming</h2>
<p><em>This tutorial assumes knowledge of basic database concepts and MySQL.</em></p>
<p>In this Java tutorial you will learn how to connect to a MySQL database.</p>
<p>Connecting to a database will likely be a common task as your Java projects progress. In this JAVA tutorial, we will use the Java Database Connectivity API (Application Programming Interface) &#8211; JDBC to deliver our data.</p>
<p>The JDBC libraries provide the means to connect your programs to a database and perform any operations upon the data that you require. To start using JDBC you need:
<ul>
<li>the <a href="http://java.sun.com/javase/downloads/index.jsp" rel="nofollow">JDK</a> (which you may already have installed)</li>
<li>a <a href="http://developers.sun.com/product/jdbc/drivers" rel="nofollow">JBDC driver</a>, which depends on the Database Management System you are using for your data.</li>
</ul>
<p>Once you have installed a driver compatible with the DBMS for your data source, create a new Java project in your IDE. Enter the following import statement at the top of your Main Class:</p>
<pre>
	//import required for database operations
import java.sql.*;
</pre>
<p>Now enter your main method (this code is for MySQL databases, with notes where alterations are required for other systems):</p>
<pre>public static void main(String[] args)
{
		//try block for sql exceptions
	try
	{
			//create driver - ALTER TO SUIT YOUR DRIVER/ DBMS
		Class.forName("com.mysql.jdbc.Driver").newInstance(); 

			//database connection code - ENTER YOUR DETAILS
		String username = "yourname";
		String password = "yourpwd";

			//URL - ALTER TO CONNECT TO YOUR DATABASE
		String dbURL = "jdbc:mysql://somedomain.com/database?user="
			+ username + "&amp;password=" + password;

			//create the connection - ALTER FOR YOUR DBMS
		java.sql.Connection myConnection =
			DriverManager.getConnection(dbURL);

			//create statement handle for executing queries
		Statement stat = myConnection.createStatement();

	}
	catch( Exception E )
	{ System.out.println( E.getMessage() );	}
}
</pre>
<p><em>If exception handling is as yet unfamiliar to you, the try and catch blocks provide your program with the ability to continue when unexpected input is received, for example when communicating with data sources. There is always a possibility of unforeseen error when your code relies on external input, in which case the code may &#8216;throw an exception&#8217;. You simply put the code that will potentially cause an exception to be thrown inside the try block, and the response to any exceptions inside the catch. If an input error (or in this case an sql error) occurs, the code will immediately jump to the catch block &#8211; all we do in this case is write the details of the error out to the console.</em></p>
<p>Your code is now ready to execute some queries on the data &#8211; to do so, enter code such as the following example at the end of (inside) the try block:</p>
<pre>//query to select all of the data from a table
String selectQuery = "Select * from MyTable";
	//get the results
ResultSet results = stat.executeQuery(selectQuery);
	//output the results
while (results.next())
{
		//example - column is called 'firstname'
	System.out.println("first name: " +
		results.getString("firstname"));
}
</pre>
<p>You can use the statement handle (the &#8216;stat&#8217; variable in the code above) to execute other SQL statements on your data, such as updates and inserts. For updates, use the syntax:</p>
<pre>//example update statement
String updateStatement =
	"Update MyTable set SomeColumn=192 where OtherColumn=12";
	//int return indicates success or failure
int updateSuccess = stat.executeUpdate(updateStatement);
System.out.println("success? "+updateSuccess);
</pre>
<p>For inserts the syntax is the same:</p>
<pre>//example insert statement
String insertStatement =
	"Insert into MyTable (col1, col2, col3)
	values (12, 'bla', 127)";
	//int return indicates success or failure
int insertSuccess = stat.executeUpdate(insertStatement);
System.out.println("success? "+insertSuccess);
</pre>
<p>You can also use the Result Set to get information about metadata:</p>
<pre>
	//get the metadata from a ResultSet
ResultSetMetaData mData = results.getMetaData();
</pre>
<p>The ResultSetMetaData object provides methods to ascertain details of the data such as table names within the database, column names within tables etc.</p>
<p>Once you&#8217;ve carried out whichever operations you need on your data, you should then close the connection:</p>
<pre>
results.close();
stat.close();
myConnection.close();
</pre>
<p>The JDBC API is widely used within Java applications due to the fact that it is standard and can be used for many relational database systems. While some of the details within the above code may need to be slightly altered for your chosen DBMS, the overall structure of your database connectivity code will remain the same.</p>
<br /> Tagged: Beginners Java Tutorial, Java, Java Datebases, MySQL and Java <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/apexmedia.wordpress.com/424/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/apexmedia.wordpress.com/424/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/apexmedia.wordpress.com/424/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/apexmedia.wordpress.com/424/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/apexmedia.wordpress.com/424/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/apexmedia.wordpress.com/424/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/apexmedia.wordpress.com/424/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/apexmedia.wordpress.com/424/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/apexmedia.wordpress.com/424/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/apexmedia.wordpress.com/424/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/apexmedia.wordpress.com/424/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/apexmedia.wordpress.com/424/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/apexmedia.wordpress.com/424/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/apexmedia.wordpress.com/424/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=learnola.com&amp;blog=4742992&amp;post=424&amp;subd=apexmedia&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://learnola.com/2009/01/07/java-tutorial-connect-to-mysql-database/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2529d8f6ec74ee1afd5fd7dd213c6d5c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">apexmedia</media:title>
		</media:content>

		<media:content url="http://apexmedia.files.wordpress.com/2008/09/case-disks1.jpg" medium="image">
			<media:title type="html">case-disks1</media:title>
		</media:content>
	</item>
		<item>
		<title>Beginners Java Tutorial &#8211; Inheritance</title>
		<link>http://learnola.com/2008/12/11/beginners-java-tutorial-inheritance/</link>
		<comments>http://learnola.com/2008/12/11/beginners-java-tutorial-inheritance/#comments</comments>
		<pubDate>Thu, 11 Dec 2008 14:04:30 +0000</pubDate>
		<dc:creator>apexmedia</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Beginners Java Tutorial]]></category>
		<category><![CDATA[Java Inheritance]]></category>
		<category><![CDATA[Java Programming]]></category>

		<guid isPermaLink="false">http://learnola.com/?p=398</guid>
		<description><![CDATA[We also have some excellent Beginners Programming Java tutorials that use high quality narrated videos and practical working files to teach the fundamentals of programming in Java Beginners Java Training Videos &#8211; Programming . Beginners Java Tutorial &#8211; Introducing Inheritance Programming can inevitably be a time-consuming and laborious process; for this reason programmers always look [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=learnola.com&amp;blog=4742992&amp;post=398&amp;subd=apexmedia&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-full wp-image-12" title="case-disks1" src="http://apexmedia.files.wordpress.com/2008/09/case-disks1.jpg?w=455" alt=""   />We also have some excellent Beginners Programming Java tutorials that use high quality narrated videos and practical working files to teach the fundamentals of programming in Java <a href="http://www.hyperteach.com/products/java-6-video-cd.htm">Beginners Java Training Videos &#8211; Programming</a></p>
<div style="border-bottom:#a3c159 2px dashed;">.</div>
<h2>Beginners Java Tutorial &#8211; Introducing Inheritance</h2>
<p>Programming can inevitably be a time-consuming and laborious process; for this reason programmers always look for ways to improve efficiency, such as the re-use of existing code. The structure of the Java language facilitates the practice of re-using code in a number of ways. One of these is Inheritance, which can have a profound effect on the way that you design your projects as a whole.</p>
<p>The basic principle in Inheritance is that you can create a Class that re-uses the code in an already existing Class by extending (inheriting from) it. The new Class inherits all of the features of the original Class, and is free to either add additional features or alter the features it has inherited, such as the way in which a method is implemented.</p>
<p>When a Class inherits from another Class, it is said to &#8216;extend&#8217; it. The original Class is referred to as the Superclass, the inheriting Class being the Subclass. All Classes in the Java language ultimately extend the Class Object, although you do not state this explicitly in your Class declarations. This is why any Class that you create will naturally provide the methods outlined in the Object Class, such as toString(), even when you didn&#8217;t declare those methods in your Class declaration.</p>
<p>Let&#8217;s create a simple example &#8211; in your IDE create a new Java project and Main Class (leave the main method empty for now). Create a second Class called MySuperClass and enter the following code:</p>
<pre>/**A Superclass ..
 */
public class MySuperClass {

	//instance variables

	/**an int */
	private int someInt;
	/**a String */
	private String someString;

	/**
	 * Constructor function
	 * @param intValue
	 * @param stringValue
	 */
	public MySuperClass(int intValue, String stringValue)
	{
		someInt=intValue;
		someString=stringValue;
	}

	/**
	 * Method outputs an arbitrary string
	 */
	public void aGreatMethod()
	{
		System.out.println("This really is a great method");
	}
}</pre>
<p>Now create another Class called MySubClass and enter the following:</p>
<pre>/**
 * MySubClass inherits from MySuperClass
 * and provides one additional method
 *
 * - This class will provide methods and
 *   variables present in the SuperClass
 *   although they are not declared here
 */
public class MySubClass extends MySuperClass {

	/**
	 * Constructor function conforms to the
	 * superclass constructor
	 * @param subIntValue
	 * @param subStringValue
	 */
	public MySubClass(int subIntValue, String subStringValue)
	{
			/* call the superclass constructor
			 * which expects an int and a string
			 */
		super(subIntValue, subStringValue);
	}

	/**
	 * Additional method provided in MySubClass
	 */
	public void anotherMethod()
	{
		System.out.println("This method is pretty good");
	}
}</pre>
<p>Now, return to your Main class and enter the following as your main method:</p>
<pre>public static void main(String[] args)
{
		//create an instance of the subclass
	MySubClass mySub = new MySubClass(99, "blah");
		//call the subclass' own method
	mySub.anotherMethod();
		//call the inherited method
	mySub.aGreatMethod();

}</pre>
<p>When you run the program you should see the following written to standard output:</p>
<pre>This method is pretty good
This really is a great method</pre>
<p>As you can see from the above code, all you need to do to extend a Class is to use the syntax &#8216;extends&#8217; in your Class declaration and &#8216;super()&#8217; in your constructor method to call the constructor for the Superclass. As well as extending your own classes (as above) you can extend Classes that already exist, either within the language itself or within any external libraries that you happen to be using.</p>
<p>One common reason for using inheritance is to provide Classes that &#8216;specialise&#8217; in some way. For example, you might have a program in which you want to represent the different sets of users of an application. These users might have some things in common but some differences &#8211; instead of having several distinct Classes in which you use sections of similar code, you could create a Superclass (e.g. User) and have several Subclasses inheriting from it. Your Superclass would provide all of the characteristics that the users have in common, while each Subclass can focus on what distinguishes it from the others.</p>
<p>Additional guidelines for using Inheritance:</p>
<ul>
<li>Each Subclass can only have one Superclass, although a Superclass can have many Subclasses.</li>
<li>You can provide an alternative implementation for any method that you inherit from a Superclass by &#8216;overriding&#8217; it &#8211; to do this you simply provide the method within your Class declaration and, providing the method signature is the same (same method name, parameter types/ number, and return type), your implementation will be the one that is called on objects of your Class.</li>
</ul>
<p><em>Advanced Java topics relating to this Java tutorial are Polymorphism, Interfaces and Abstract Classes.</em></p>
<br /> Tagged: Beginners Java Tutorial, Java Inheritance, Java Programming <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/apexmedia.wordpress.com/398/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/apexmedia.wordpress.com/398/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/apexmedia.wordpress.com/398/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/apexmedia.wordpress.com/398/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/apexmedia.wordpress.com/398/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/apexmedia.wordpress.com/398/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/apexmedia.wordpress.com/398/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/apexmedia.wordpress.com/398/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/apexmedia.wordpress.com/398/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/apexmedia.wordpress.com/398/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/apexmedia.wordpress.com/398/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/apexmedia.wordpress.com/398/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/apexmedia.wordpress.com/398/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/apexmedia.wordpress.com/398/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=learnola.com&amp;blog=4742992&amp;post=398&amp;subd=apexmedia&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://learnola.com/2008/12/11/beginners-java-tutorial-inheritance/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2529d8f6ec74ee1afd5fd7dd213c6d5c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">apexmedia</media:title>
		</media:content>

		<media:content url="http://apexmedia.files.wordpress.com/2008/09/case-disks1.jpg" medium="image">
			<media:title type="html">case-disks1</media:title>
		</media:content>
	</item>
		<item>
		<title>Beginners Java Tutorial &#8211; Building a User Interface</title>
		<link>http://learnola.com/2008/12/10/beginners-java-tutorial-building-a-user-interface/</link>
		<comments>http://learnola.com/2008/12/10/beginners-java-tutorial-building-a-user-interface/#comments</comments>
		<pubDate>Wed, 10 Dec 2008 12:44:29 +0000</pubDate>
		<dc:creator>apexmedia</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Beginners Java Programming]]></category>
		<category><![CDATA[Java Interface]]></category>
		<category><![CDATA[Java Tutorial]]></category>

		<guid isPermaLink="false">http://learnola.com/?p=378</guid>
		<description><![CDATA[We also have some excellent Beginners Programming Java tutorials that use high quality narrated videos and practical working files to teach the fundamentals of programming in Java Beginners Java Tutorial Videos . Beginners Java Tutorial &#8211; Building  User Interfaces The Java language features a range of resources for building user interfaces. In this tutorial, we [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=learnola.com&amp;blog=4742992&amp;post=378&amp;subd=apexmedia&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-full wp-image-12" title="case-disks1" src="http://apexmedia.files.wordpress.com/2008/09/case-disks1.jpg?w=455" alt=""   />We also have some excellent Beginners Programming Java tutorials that use high quality narrated videos and practical working files to teach the fundamentals of programming in Java <a href="http://www.hyperteach.com/products/java-6-video-cd.htm">Beginners Java Tutorial Videos</a></p>
<div style="border-bottom:#a3c159 2px dashed;">.</div>
<h2>Beginners Java Tutorial &#8211; Building  User Interfaces</h2>
<p>The Java language features a range of resources for building user interfaces. In this tutorial, we will use Swing and AWT to build a simple Graphical User Interface. The Swing libraries provide the graphical elements and AWT allows you to respond to user interaction.</p>
<p>Open your chosen IDE and create a new project. Create a Main Class (with your main method in it, but leave it empty for now) and a second Class, called MyGUI. In this Class, enter the following (don&#8217;t be alarmed if some of the syntax is unfamiliar, explanation follows):</p>
<pre>/**
 * MyGUI User Interface Class
 */

//imports for graphics and user interaction
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

/**
 * MyGUI class represents a graphical user interface
 * @author Your Name
 */
public class MyGUI extends JFrame implements ActionListener {

	/**
	 * Constructor function creates and displays
	 * the basic elements in the GUI
	 */
	public MyGUI()
	{
			//constructor code ...

	}

	/**
	 * actionPerformed will determine how the program
	 * responds to user interaction
	 */
	public void actionPerformed(ActionEvent e)
	{
			//event code ...

	}
}</pre>
<p>Let&#8217;s look at the individual code elements:</p>
<ul>
<li>The import statements allow us to use the Swing and AWT libraries for building our interface</li>
<li>In the line:
<ul>
<li>&#8216;extends JFrame&#8217; relies on the notion of Inheritance, but don&#8217;t worry if you haven&#8217;t come across it before, at this stage you can simply treat the line as a formula that you use for any user interface Class.<br />
<em>The Class inherits from the Class JFrame, meaning JFrame is its superclass.</em></li>
<li>&#8216;implements ActionListener&#8217; has to do with Java Interface declarations &#8211; again, if this is unfamiliar to you don&#8217;t worry, just use this code whenever you need to respond to user interaction.<br />
<em>The Class implements the ActionListener interface, meaning that it must provide the methods outlined in that Interface declaration.</em></li>
</ul>
</li>
<pre>public class MyGUI extends JFrame implements
ActionListener</pre>
<li>The method actionPerformed(ActionEvent e) must be provided whenever ActionListener is being implemented &#8211; this is where the code responding to user interaction will go. More on this follows.</li>
</ul>
<p>Now we will add some &#8216;widgets&#8217; to our GUI, to do this we need to create an instance variable for each, and constructor code to display them.</p>
<p>The first thing to do within the constructor is specify the window properties, such as size, location etc. Then, we need to create Panels to hold our widgets. The default layout for a JFrame GUI is called &#8216;Border Layout&#8217;; this means that items can bee added in positions North, South, East, West and Center. However, you can change the layout, as we will in one section below, in this case to Grid Layout, in which you can have a specified number of rows and columns. When you do this, items are given consecutive positions left to right/ top to bottom as you add them to the GUI (first being leftmost/topmost). The widgets themselves need to be instantiated within the constructor also, as you can see below. Our GUI will have a button, a checkbox and two radio buttons &#8211; enter the code:</p>
<pre>/**
 * MyGUI User Interface Class
 */

//imports for graphics and user interaction
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

/**
 * MyGUI class represents a graphical user interface
 * @author Your Name
 */
public class MyGUI extends JFrame implements ActionListener {

		//instance variables - elements in the GUI
	private JButton myButton;
	private JRadioButton firstRadio, secondRadio;
	private JCheckBox myCheck;

	/**
	 * Constructor function creates and displays
	 * the basic elements in the GUI
	 */
	public MyGUI()
	{
			//set the window properties
		setTitle("My GUI");
		setSize(200, 200);
		setLocation(100, 100);

			//create Panels
		JPanel northPanel = new JPanel();
		JPanel centerPanel = new JPanel();
		JPanel southPanel = new JPanel();
		add(northPanel, "North");
		add(centerPanel, "Center");
		add(southPanel, "South");

			//create widgets
		myButton = new JButton("a button");
		firstRadio = new JRadioButton("pick me");
		secondRadio = new JRadioButton("or me");
		myCheck = new JCheckBox("check me");

			//add widgets to the GUI - button
		northPanel.add(myButton);

			//create grid layout for centre (radio buttons)
		GridLayout myGrid = new GridLayout(1, 2);//1 row, 2 cols
		centerPanel.setLayout(myGrid);
		centerPanel.add(firstRadio);
		centerPanel.add(secondRadio);
			//create button group - only one may be selected
		ButtonGroup myGroup = new ButtonGroup();
		myGroup.add(firstRadio);
		myGroup.add(secondRadio);

			//add checkbox
		southPanel.add(myCheck);

			//make the GUI visible
		setVisible(true);
	}

	/**
	 * actionPerformed will determine how the program
	 * responds to user interaction
	 */
	public void actionPerformed(ActionEvent e)
	{
			//event code ...

	}
}</pre>
<p>Try not to be intimidated by the amount of code, creating user interfaces can be long-winded but really is simple to program. Now, return to your main method and enter the following:</p>
<pre>	//create an instance of the MyGUI class
MyGUI myGui = new MyGUI();</pre>
<p>Run your program, it should look something like this:</p>
<p><img class="alignleft size-full wp-image-384" title="gui" src="http://apexmedia.files.wordpress.com/2008/12/gui.jpg?w=455" alt="gui"   /></p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p>You&#8217;ll notice that although you can interact with the buttons etc, nothing actually happens when you do so &#8211; let&#8217;s add code to detect this interaction. At the end of your MyGUI constructor code (before setVisible) add the following:</p>
<pre>	//listen for user interaction
myButton.addActionListener(this);
firstRadio.addActionListener(this);
secondRadio.addActionListener(this);
myCheck.addActionListener(this);</pre>
<p>Now, whenever someone interacts with your buttons, the actionPerformed method will be called, passing information about the &#8216;event&#8217; in the ActionEvent parameter. In the actionPerformed method, we therefore need to decide how to respond:</p>
<pre>/**
 * actionPerformed will determine how the program
 * responds to user interaction
 */
public void actionPerformed(ActionEvent e)
{
		//which component had an event?
	if(e.getSource()==myButton)
	{
			//the button
		System.out.println("Someone pressed the button!");
	}
	else if(e.getSource()==firstRadio)
	{
			//first radio button
		System.out.println("first");
	}
	else if(e.getSource()==secondRadio)
	{
			//second radio
		System.out.println("second");
	}
	else
	{
			//must be checkbox
		boolean selected = myCheck.isSelected();
		System.out.println((selected ? "checked" : "unchecked"));
	}

}</pre>
<p>Run the program and see what happens when you interact with the buttons now, you should see results printed to the output console.</p>
<p>You never call the actionPerformed method explicitly in your own code, it is called automatically when events are detected on any component you have added and ActionListener to. Obviously your real applications will have more sophisticated ways of responding to events, but this overview should indicate the basic pattern that you can adopt to create user interfaces in Java. The Swing library contains numerous resources you can experiment with such as TextAreas/Fields, ComboBoxes and more.</p>
<br /> Tagged: Beginners Java Programming, Java Interface, Java Tutorial <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/apexmedia.wordpress.com/378/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/apexmedia.wordpress.com/378/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/apexmedia.wordpress.com/378/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/apexmedia.wordpress.com/378/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/apexmedia.wordpress.com/378/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/apexmedia.wordpress.com/378/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/apexmedia.wordpress.com/378/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/apexmedia.wordpress.com/378/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/apexmedia.wordpress.com/378/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/apexmedia.wordpress.com/378/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/apexmedia.wordpress.com/378/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/apexmedia.wordpress.com/378/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/apexmedia.wordpress.com/378/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/apexmedia.wordpress.com/378/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=learnola.com&amp;blog=4742992&amp;post=378&amp;subd=apexmedia&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://learnola.com/2008/12/10/beginners-java-tutorial-building-a-user-interface/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2529d8f6ec74ee1afd5fd7dd213c6d5c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">apexmedia</media:title>
		</media:content>

		<media:content url="http://apexmedia.files.wordpress.com/2008/09/case-disks1.jpg" medium="image">
			<media:title type="html">case-disks1</media:title>
		</media:content>

		<media:content url="http://apexmedia.files.wordpress.com/2008/12/gui.jpg" medium="image">
			<media:title type="html">gui</media:title>
		</media:content>
	</item>
		<item>
		<title>Java Tutorial &#8211; Organizing your Code</title>
		<link>http://learnola.com/2008/12/08/java-tutorial-organizing-your-code/</link>
		<comments>http://learnola.com/2008/12/08/java-tutorial-organizing-your-code/#comments</comments>
		<pubDate>Mon, 08 Dec 2008 21:07:04 +0000</pubDate>
		<dc:creator>apexmedia</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Beginners Java Tutorial]]></category>
		<category><![CDATA[Java Programming]]></category>
		<category><![CDATA[UML]]></category>

		<guid isPermaLink="false">http://learnola.com/?p=376</guid>
		<description><![CDATA[Java Tutorial &#8211; Organising Java Projects As your programs grow in size and complexity, organisation and documentation will become more important. Applications developed in Java must be well-constructed and documented in order to function within the Object Oriented design model. Under this model, applications comprise a set of components interacting with one another &#8211; for [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=learnola.com&amp;blog=4742992&amp;post=376&amp;subd=apexmedia&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h2>Java Tutorial &#8211; Organising  Java Projects</h2>
<p>As your programs grow in size and complexity, organisation and documentation will become more important. Applications developed in Java must be well-constructed and documented in order to function within the Object Oriented design model. Under this model, applications comprise a set of components interacting with one another &#8211; for this to be possible, the elements within must be clearly defined and explained. Even when you develop your own smaller projects, you will find that spending a little time and thought on these choices will save you a lot of headaches in the long run.</p>
<p>There are a series of simple measures that can contribute to a well-organised project, for example, the simple act of using plenty of whitespace and indentation in your code instantly makes it more readable, while this sounds boring and very uneventful .</p>
<h3>Dividing up Requirements</h3>
<p>It can be tempting, when starting a project, to sit down and immediately produce code, but resisting this urge can make life a lot easier. Once you have a set of requirements for your application, it can be extremely helpful to work out a &#8216;high-level&#8217; plan before you start to write any code. For example: split the requirements into related sections, then use these to decide what your packages and classes will be. Even if you find that your implementation causes you to alter this initial plan, it provides a much more coherent starting point.</p>
<p>There are various modelling tools that can help this process, such as UML (Unified Modelling Language) &#8211; however, even if you decide not to choose such a formal approach, the simple act of splitting the requirements into groups can help you to visualise how you are going to solve the problems at hand.</p>
<h3>Java Naming Conventions </h3>
<p>It is well worth spending a few moments during coding to decide on appropriate names for variables, methods, classes and packages. In addition to the fact that this makes your work much more amenable to being used in other applications, it also makes your own development process easier. When you look back at a piece of code that you wrote some time before but have forgotten the details of, meaningful variable and method names will help you to understand it far quicker than if you have to read and process each line of code in your head! Although it may seem cumbersome at times, using whole words in your names can make your code much more readable.</p>
<p>For the same reason, observing the standard naming conventions for the language is always a good idea. In Java, this includes the following:</p>
<ul>
<li>variables should start lowercase, with uppercase letters indicating words within, e.g. myNumber, costPerPortion.</li>
<li>method names should indicate (normally using verbs) what the method does, e.g. getCost, displayNames.
<ul>
<li>methods used to get and set values should use the conventions getValue (e.g. getCost) and setValue (e.g. setCost) respectively.</li>
</ul>
</li>
</ul>
<h3>Comments and Documents</h3>
<p>Regardless of whether you are working on your own or as part of a team, the inclusion of informative comments in your code will always help the development along. The Java language features a variety of different types of comment:</p>
<p>Single line comments are used for short pieces of information throughout your code:</p>
<pre>
	//print each name in the array
for(int i=0; i</pre>
<p>Multiline comments are used for more lengthy explanations, particularly if your code features a complex algorithm:</p>
<pre>
	/*  This algorithm does the following:
		-first it does this
		-then it does this
		-and so on
	*/
for(int i=0; i</pre>
<h3>Javadoc</h3>
<p>Java has its own system of documentation that is effectively built-in to the language. You can use Javadoc to automatically generate html documentation for your projects, and all you need to do is include Javadoc comments in your code:</p>
<pre>
/**
Method calculates total cost from individual cost
... more explanation ...
@param someNumber -int value representing individual cost
@return totalCost -int value representing total cost
*/
public int getTotalCost(int someNumber)
{
	//method code calculations..

	return totalCost;
}
</pre>
<p>Javadoc generates html based on such comments, which contain special tags such as @param and @return &#8211; if you include these the Javadoc will display this information in a standardised way. You should include Javadoc comments immediately before Class declarations, instance variable declarations, methods and constructors. The <a href="http://java.sun.com/javase/6/docs/api/" title="Java 6 API" rel="nofollow">Java API</a> is an example of Javadoc that you can view.</p>
<br /> Tagged: Beginners Java Tutorial, Java Programming, UML <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/apexmedia.wordpress.com/376/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/apexmedia.wordpress.com/376/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/apexmedia.wordpress.com/376/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/apexmedia.wordpress.com/376/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/apexmedia.wordpress.com/376/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/apexmedia.wordpress.com/376/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/apexmedia.wordpress.com/376/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/apexmedia.wordpress.com/376/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/apexmedia.wordpress.com/376/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/apexmedia.wordpress.com/376/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/apexmedia.wordpress.com/376/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/apexmedia.wordpress.com/376/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/apexmedia.wordpress.com/376/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/apexmedia.wordpress.com/376/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=learnola.com&amp;blog=4742992&amp;post=376&amp;subd=apexmedia&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://learnola.com/2008/12/08/java-tutorial-organizing-your-code/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2529d8f6ec74ee1afd5fd7dd213c6d5c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">apexmedia</media:title>
		</media:content>
	</item>
		<item>
		<title>Beginners Java Tutorial &#8211; Methods &#8211; Control Structures</title>
		<link>http://learnola.com/2008/12/03/beginners-java-tutorial-methods-control-structures/</link>
		<comments>http://learnola.com/2008/12/03/beginners-java-tutorial-methods-control-structures/#comments</comments>
		<pubDate>Wed, 03 Dec 2008 17:44:28 +0000</pubDate>
		<dc:creator>apexmedia</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Beginners Java Tutorial]]></category>
		<category><![CDATA[programming in Java]]></category>

		<guid isPermaLink="false">http://apexmedia.wordpress.com/?p=354</guid>
		<description><![CDATA[Java &#8211; Methods and Control Structures This Java tutorial is intended for people in the early stages of beginning Java programming. When you compile and run a Java program, the JVM executes whatever is within the main method. These instructions are carried out sequentially unless dictated otherwise by the code itself, for example by using [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=learnola.com&amp;blog=4742992&amp;post=354&amp;subd=apexmedia&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h2>Java &#8211; Methods and Control Structures</h2>
<p><em>This Java tutorial is intended for people in the early stages of beginning Java programming.</em></p>
<p>When you compile and run a Java program, the JVM executes whatever is within the main method. These instructions are carried out sequentially unless dictated otherwise by the code itself, for example by using control structures, calling methods or creating Objects. This tutorial introduces basic control structures and method invocation in Java.</p>
<p>When you start programming in any language, it can seem intuitive to think of a program as a series of instructions that are executed in a linear fashion. However, when building applications, you will structure your code in a number of different ways.</p>
<p>For example, if your application allows user interaction, whatever code is executed will depend on what the user does at any point. Whenever your programs use external input, whether from user interaction or e.g. where content comes from a database, you need to tailor the behaviour of your code to suit the particular input that it receives.</p>
<h3>Conditionals</h3>
<p>Imagine you have an application in which a series of products are being displayed, the product details being pulled from a database. Your display will look messy if the product names are longer than 20 characters so you decide to display only the first 20, cropping the remaining letters off. In your IDE, create a new Java project and enter the following in your main method:</p>
<pre>//main method
public static void main(String[] args)
{
		//product name - would have come from database
	String productName = "Deluxe Man-Size Tissues";
		//name as it will be displayed
	String displayName = "";
		//conditional statement
	if(productName.length()&gt;20)
		displayName = productName.substring(0, 20);
	else
		displayName = productName;
		//test the result
	System.out.println(displayName);

}</pre>
<p>In this trivial example, the product name is &#8216;hard-coded&#8217; into the program but imagine that when you sit down to write the program, you have no idea what String value will be in that variable. Look at the conditional statement and think about what happens at runtime. If the variable name is indeed longer than 20 chars, only the code under the &#8216;if&#8217; will execute, with the &#8216;else&#8217; being ignored. If the name is 20 chars or less, only the &#8216;else&#8217; executes, with the &#8216;if&#8217; ignored. The statement within the &#8216;if&#8217; brackets (&#8216;productName.length()&gt;20&#8242;) is a test which, when carried out, returns a true or false value &#8211; if true the instructions carry out the &#8216;if&#8217;, if false they jump to &#8216;else&#8217;. When you run the program, it should output &#8220;Deluxe Man-Size Tiss&#8221; &#8211; experiment by changing the productName variable.</p>
<h3>Loops in Java</h3>
<p>Another basic way to introduce a control structure to your code is by using loops. You will often find when programming that you need to carry out repetitive processing &#8211; you can reduce the amount of code that you actually need to write by using &#8216;while&#8217; or &#8216;for&#8217; loops.</p>
<p>Imagine you have an array of products whose names you want to display &#8211; enter and run the following code:</p>
<pre>//product array
String[] products = {"Hats", "Shoes", "Ties"};
	//print each to standard output
for(int i=0; i</pre>
<p>The code within this loop will execute as many times as there are elements in the array. What happens when the instructions reach the loop:</p>
<ul>
<li>The first time the loop is carried out, the value 0 is assigned to the i variable.</li>
<li>The test i&lt;products.length is carried out, returning a true or false value.
<ul>
<li>If the test returns true
<ul>
<li>the content of the loop (printing out the value at position i in the array) is carried out</li>
<li>i++ is executed (i is incremented to keep track of how many times the loop has executed)</li>
<li>the loop is then re-entered &#8211; the test carried out again to see if i is still less than the length of the array</li>
</ul>
</li>
<li>If the test returns false, the loop is abandoned and whatever code lies after it is executed.</li>
</ul>
</li>
</ul>
<p>A while loop can be used to the same effect:</p>
<pre>int j=0;
while(j</pre>
<h3>Methods</h3>
<p>You will often find that you are carrying out the same processing in more than one place within your program, for example, imagine you have several arrays that you wish to display the contents of in the same way &#8211; you can define your own methods to do this. In your project, enter the following:</p>
<pre>//class declaration
public class MyClass
{
		//main method
	public static void main(String[] args)
	{
			//product array
		String[] products = {"Hats", "Shoes", "Ties"};
			//call the method, passing it the product array
		int elems = printElements(products);
			//test the result
		System.out.println(elems + " printed");
	}

		//method prints the elements in a given array
	public static int printElements(String[] elements)
	{
		for(int e=0; e</pre>
<p>When creating your own methods like this, you have to decide what the type and number of parameters are, what the return type is (int in this case, void if there is none), as well as the content and name of the method (try to make this meaningful but concise if possible).</p>
<p>You can then call the method passing it any other String array and it will perform the same action with it &#8211; try it by creating a second array with different length and content.</p>
<br /> Tagged: Beginners Java Tutorial, programming in Java <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/apexmedia.wordpress.com/354/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/apexmedia.wordpress.com/354/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/apexmedia.wordpress.com/354/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/apexmedia.wordpress.com/354/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/apexmedia.wordpress.com/354/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/apexmedia.wordpress.com/354/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/apexmedia.wordpress.com/354/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/apexmedia.wordpress.com/354/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/apexmedia.wordpress.com/354/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/apexmedia.wordpress.com/354/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/apexmedia.wordpress.com/354/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/apexmedia.wordpress.com/354/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/apexmedia.wordpress.com/354/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/apexmedia.wordpress.com/354/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=learnola.com&amp;blog=4742992&amp;post=354&amp;subd=apexmedia&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://learnola.com/2008/12/03/beginners-java-tutorial-methods-control-structures/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2529d8f6ec74ee1afd5fd7dd213c6d5c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">apexmedia</media:title>
		</media:content>
	</item>
		<item>
		<title>Beginners Java Programming Tutorial &#8211; Datatypes</title>
		<link>http://learnola.com/2008/12/03/beginners-java-programming-tutorial-datatypes/</link>
		<comments>http://learnola.com/2008/12/03/beginners-java-programming-tutorial-datatypes/#comments</comments>
		<pubDate>Wed, 03 Dec 2008 16:54:10 +0000</pubDate>
		<dc:creator>apexmedia</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Beginners Java Tutorial]]></category>
		<category><![CDATA[Java Datatypes]]></category>
		<category><![CDATA[Java Programming]]></category>

		<guid isPermaLink="false">http://apexmedia.wordpress.com/?p=350</guid>
		<description><![CDATA[We also have some excellent Beginners Programming Java tutorials that use high quality narrated videos and practical working files to teach the fundamentals of programming in Java Beginners Java Tutorial Videos &#8211; Programming . Java &#8211; Datatypes and Variables Beginners Java Tutorial on Datatypes and Variables, ideal for the novice who is just starting to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=learnola.com&amp;blog=4742992&amp;post=350&amp;subd=apexmedia&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-full wp-image-12" title="case-disks1" src="http://apexmedia.files.wordpress.com/2008/09/case-disks1.jpg?w=455" alt=""   />We also have some excellent Beginners Programming Java tutorials that use high quality narrated videos and practical working files to teach the fundamentals of programming in Java <a href="http://www.hyperteach.com/products/java-6-video-cd.htm">Beginners Java Tutorial Videos &#8211; Programming</a></p>
<div style="border-bottom:#a3c159 2px dashed;">.</div>
<h2>Java &#8211; Datatypes and Variables</h2>
<p>Beginners Java Tutorial on Datatypes and Variables, ideal for the novice who is just starting to learn programming in JAVA</p>
<p>In order to program effectively in Java, you need to understand a little about the different datatypes in the language. A variable in Java can essentially be one of two things: a primitive type or an Object reference. To create efficient programs, you need to think about which types to use, as this will have a direct effect on performance.</p>
<p>The Java language is &#8216;strongly typed&#8217;, which means that when you declare a variable, you have to specify the type:</p>
<pre>int myNum = 1;
String myString = "hello";
Object myObject = new Object();</pre>
<p>The advantage to this is that you have a degree of control over the underlying implementation (and therefore efficiency) of your projects. To make informed choices about datatypes, let&#8217;s look at the ways in which they are represented in memory.</p>
<h3>Primitives</h3>
<p>The Primitive types in Java are <strong>int</strong>, <strong>char</strong>, <strong>boolean</strong>, <strong>byte</strong>, <strong>double</strong>, <strong>float</strong>, <strong>long</strong> and <strong>short</strong>. Primitive type variables can be given a value when you declare them, and the values are stored in stack memory:</p>
<pre>int myNum = 1;
//in this case the value 1 is stored on the stack</pre>
<p>In contrast, reference types are stored in heap memory, with only the Object reference on the stack (more on this below). You don&#8217;t need to understand the details of how your variables are stored in the computer&#8217;s hardware to program efficiently, as there are simple practices that will minimise the amount of memory that you use. In general, primitive types use less memory than Objects.</p>
<p>When it comes to choosing between primitive types, you should also try to minimise memory usage, e.g. for integer arithmetic: an <strong>int</strong> uses up less memory than a <strong>long</strong>; for floating point: a <strong>float</strong> uses less than a <strong>double</strong> &#8211; naturally there is a trade-off involved in this choice, since the larger types offer a greater range of possible values.</p>
<p><em>Note: The primitive types also have associated Wrapper classes (e.g. Integer). As well as storing the value (of e.g. an int), variables of these types can have methods called on them. However, being of the reference type, they occupy space in heap memory, and as such you should avoid using them unless you have specific reasons for using their associated methods.</em></p>
<h3>Reference Types</h3>
<p>When you create an Object, the JVM allocates a section of heap memory for it, with the Object reference stored on the stack. In this example:</p>
<pre>Object myObject = new Object();</pre>
<p>your myObject variable is essentially a pointer to a location in memory. The data etc contained within your Object is stored at this location. Given that this happens every time you create an Object, you can imagine that the amount of memory used up by your programs will quickly accumulate. However, there are more simple measures you can take to minimise this.</p>
<h4>Garbage Collection</h4>
<p>The JVM uses &#8216;garbage collection&#8217; to free up areas of memory that are no longer being used. A location used by an Object in your program will be considered a candidate for garbage collection, if there are no longer any Object references pointing to it. For this reason, you need to think about where you declare variables, and for how much of the processing they need to remain available.</p>
<p>For example, if you consider the following trivial example:</p>
<pre>//print the string backwards if it's at least 10 chars
String myString = "blahdeblahdeblah";
String backString = "";
if(myString.length()&gt;=10)
{
	for(int i=myString.length()-1; i&gt;=0; i--)
	{
		backString += myString.charAt(i);
	}
	System.out.println(backString);
}</pre>
<p>Providing you don&#8217;t need the backString variable further down in your program, it is better to declare it inside the &#8216;if&#8217; statement:</p>
<pre>//print the string backwards if it's at least 10 chars
String myString = "blahdeblahdeblah";
if(myString.length()&gt;=10)
{
	String backString = "";
	for(int i=myString.length()-1; i&gt;=0; i--)
	{
		backString += myString.charAt(i);
	}
	System.out.println(backString);
}</pre>
<p>The backString variable is now &#8216;local&#8217; to the conditional &#8216;if&#8217; statement; once that statement has finished executing, the variable is no longer needed and is therefore garbage. In the first example, the variable had greater &#8216;scope&#8217;, and remained available longer than necessary, using up memory. You can also use this principle of &#8216;localising&#8217; variables with the primitive types.</p>
<p><em>Note: The syntax for some reference types such as String and Array can be confusing at first &#8211; although these look the same as primitive types in that you can assign a value to them as you declare them (rather than using the keyword &#8216;new&#8217;, as with most other classes), they are Objects and occupy memory as such.</em></p>
<p><em>Next <a href="http://learnola.com/2008/12/03/beginners-java-tutorial-methods-control-structures/">Java Tutorial &#8211; Methods and Control Structures</a></em></p>
<br /> Tagged: Beginners Java Tutorial, Java Datatypes, Java Programming <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/apexmedia.wordpress.com/350/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/apexmedia.wordpress.com/350/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/apexmedia.wordpress.com/350/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/apexmedia.wordpress.com/350/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/apexmedia.wordpress.com/350/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/apexmedia.wordpress.com/350/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/apexmedia.wordpress.com/350/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/apexmedia.wordpress.com/350/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/apexmedia.wordpress.com/350/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/apexmedia.wordpress.com/350/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/apexmedia.wordpress.com/350/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/apexmedia.wordpress.com/350/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/apexmedia.wordpress.com/350/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/apexmedia.wordpress.com/350/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=learnola.com&amp;blog=4742992&amp;post=350&amp;subd=apexmedia&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://learnola.com/2008/12/03/beginners-java-programming-tutorial-datatypes/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2529d8f6ec74ee1afd5fd7dd213c6d5c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">apexmedia</media:title>
		</media:content>

		<media:content url="http://apexmedia.files.wordpress.com/2008/09/case-disks1.jpg" medium="image">
			<media:title type="html">case-disks1</media:title>
		</media:content>
	</item>
		<item>
		<title>Beginners Java Tutorial &#8211; Objects and Classes</title>
		<link>http://learnola.com/2008/11/24/beginners-java-tutorial-objects-and-classes/</link>
		<comments>http://learnola.com/2008/11/24/beginners-java-tutorial-objects-and-classes/#comments</comments>
		<pubDate>Mon, 24 Nov 2008 11:10:29 +0000</pubDate>
		<dc:creator>apexmedia</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Java Programming]]></category>
		<category><![CDATA[Java Tutorial]]></category>

		<guid isPermaLink="false">http://apexmedia.wordpress.com/?p=321</guid>
		<description><![CDATA[We also have some excellent Beginners Programming Java tutorials that use high quality narrated videos and practical working files to teach the fundamentals of programming in Java Beginners Java Tutorial Videos &#8211; Programming . Java Tutorial - Objects and Classes This Java tutorial assumes some very basic Java knowledge, e.g. method syntax. Objects are the key [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=learnola.com&amp;blog=4742992&amp;post=321&amp;subd=apexmedia&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-full wp-image-12" title="case-disks1" src="http://apexmedia.files.wordpress.com/2008/09/case-disks1.jpg?w=455" alt=""   />We also have some excellent Beginners Programming Java tutorials that use high quality narrated videos and practical working files to teach the fundamentals of programming in Java <a href="http://www.hyperteach.com/products/java-6-video-cd.htm">Beginners Java Tutorial Videos &#8211; Programming</a></p>
<div style="border-bottom:#a3c159 2px dashed;">.</div>
<h2>Java Tutorial - Objects and Classes</h2>
<p><em>This Java tutorial assumes some very basic Java knowledge, e.g. method syntax.</em></p>
<p>Objects are the key to building robust and efficient Java applications. When developing a large or complex system, developers begin the design process by dividing up the various project requirements into application components. These are ultimately represented by Objects within the application, and are implemented in code by Class declarations. While it might be difficult to perceive the advantages to this technique while you&#8217;re learning (and working on small projects), if you adopt the right practices at this stage, you will develop the skills required for professional Java development.</p>
<h3>Creating Objects</h3>
<p>In your Java IDE, create a new Project called MyFirstObject, with Main Class MyFirstObject (if you&#8217;re using Netbeans myfirstobject.MyFirstObject with myfirstobject as the package name). Inside your MyFirstObject Class enter the following:</p>
<pre>//class declaration
public class MyFirstObject
{
//main method
public static void main(String[] args)
	{
//code here will be executed when the program is run
	}
}</pre>
<p>Using Objects is a way of dividing up responsibility for the different parts of an application. You can do this in a variety of ways: for example, you can carry out some of your program&#8217;s tasks within separate methods, calling these from the main part of your code. Using Objects is similar to this, but each Object requires a Class declaration, which you create in a separate .java file.</p>
<p>The Objects that you may have already used, such as those representing Java datatypes String, Array etc also have their own Class declarations &#8211; these are built into the Java language itself, and although you can&#8217;t see the code, you can see an overview as part of the <a title="Java 6 API" href="http://java.sun.com/javase/6/docs/api/">Java API</a> (Application Programming Interface). The Objects that you define yourself will function in the same way &#8211; let&#8217;s create a simple example.</p>
<p>In your project, create a new Class called MyHelper, entering the following:</p>
<pre>	//class declaration
public class MyHelper {

		//instance variable
	private int helperNum;

		//constructor method
	public MyHelper()
	{
		helperNum=1;
	}

		//public method
	public int getNumber()
	{
		return helperNum;
	}
}</pre>
<p>The above code is a simple Class declaration specifying the properties that any Object of the MyHelper Class will have &#8211; next we will create an &#8216;instance&#8217; of the MyHelper Class within our Main Class, but first let&#8217;s look at the Class declaration.</p>
<h4>Instance Variables</h4>
<p>Instance variables represent any data that should be stored in every instance of your Object, meaning that every time you create a MyHelper Object it will contain a helperNum integer variable. Instance variables should always be private, so that their value cannot be changed except within the Class declaration itself &#8211; more on this later.</p>
<h4>Constructor method</h4>
<p>You can see that the constructor method looks the same as any other method, except that it doesn&#8217;t have a return type specified &#8211; this is because the constructor method is called when an Object of the Class is created (using the keyword &#8216;new&#8217;), and what it returns is &#8211; an Object of the Class. The constructor method should always have the same name as the Class. Within the constructor method, you carry out &#8216;initialisation&#8217;, meaning that you assign a value to your instance variables &#8211; when the constructor method has executed, none of your instance variables should be left without a value, as this can make your program unpredictable.</p>
<h4>Public Method</h4>
<p>The declaration contains one public method, &#8216;getNumber&#8217;, which can be called on any Object of the Class. Although the example may seem trivial, it is common to have methods which either set or return the value of an instance variable.</p>
<p><em>The reason for such methods relates to your instance variables being private. The basic principle underlying Object Oriented development is that your Objects have a &#8216;well-defined&#8217; interface &#8211; this means that all access to the data contained within a Class should be through its methods. If the instance variables were public, external code would be free to change their values directly, which can be dangerous, since external code may not be aware of the implementation details for the Class. If you restrict all access to your instance variables, to the public methods in a Class, you can carry out any checks etc there to ensure that your data is not assigned invalid values.</em></p>
<h3>Using your Class</h3>
<p>Now go back to your Main Class and enter the following inside your main method:</p>
<pre>//code here will be executed when the program is run
//create a MyHelper object
MyHelper mh = new MyHelper();
//call a method on it, assign the result to a variable
int num = mh.getNumber();
//write the variable out for testing
System.out.println(num);</pre>
<p>Compile and run your program and you should see the number 1 written to standard output. You create an Object of your Class, and call methods on it, in exactly the same way as any other Object. From your main method, you can call any methods on the MyHelper Object that are declared as public inside the Class.</p>
<p>A Class may also have private methods that are for use within the Class only. For example, one of your public Class methods may involve complex or repetitive processing that you decide to separate out into its own method, calling this from the public method &#8211; in this case the separate method should be declared as private, as this method relates to the implementation of the Class itself, which external code should not have access to.</p>
<h3>Object principles</h3>
<p>If you&#8217;re new to Object Oriented development in general, it can help to think in terms of &#8216;black boxes&#8217;. One of the principles that makes Java suited to developing large projects, is the idea that any application developed in Java can in turn be used by anyone else as a component in another application. Many open source projects use Java, with people sharing resources that they have developed in the language.</p>
<p>For this approach to be feasible, it must not be necessary for someone using a component to have to understand all of the implementation details within it. So long as there is a &#8216;well-defined&#8217; interface, you should be able to make use of external Java libraries and resources while knowing nothing about what goes on inside them &#8211; in the same way that you can use a String or Array without having to understand how it is implemented in the underlying code. In this approach, you can think of Objects as &#8216;black boxes&#8217; &#8211; code external to the Class should be able to make use of it without having to be aware of the inner code. When you develop your own Objects, you should adopt the same principle &#8211; even if you&#8217;re developing an application single-handed, this approach makes for programs that are faster to build and easier to debug.</p>
<h3>More on Classes</h3>
<p>As a final note, you should be aware that you can have more than one constructor method in a Class, each one taking different parameters. In this case whichever method is called is dictated by what parameters are passed when an Object of the Class is created. To demonstrate, add a second constructor to your Class, beneath the existing one:</p>
<pre>	//class declaration
public class MyHelper {

//instance variable
	private int helperNum;

//constructor method
	public MyHelper()
	{
		helperNum=1;
	}
//second constructor - takes a parameter
	public MyHelper(int value)
	{
		helperNum=value;
	}

//public method
	public int getNumber()
	{
		return helperNum;
	}
}</pre>
<p>Now add the following in your main method, after the existing code:</p>
<pre>	//create an object passing int parameter
MyHelper mh2 = new MyHelper(2);
int num2 = mh2.getNumber();
System.out.println(num2);</pre>
<p>When you run your program, this time it should output 1 and then 2 for the new Object. Whichever constructor matches the type and number of parameters passed is the one that&#8217;s called during Object creation.</p>
<p>When using Objects in your programs, you should try to decide what the various Classes will be at the outset, by dividing up the different requirements that your project has, and assigning responsibility for these to your set of Objects.</p>
<p>Next <a href="http://learnola.com/2008/12/03/beginners-java-programming-tutorial-datatypes/">Java Tutorial &#8211; Datatypes .</a></p>
<br /> Tagged: Java Programming, Java Tutorial <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/apexmedia.wordpress.com/321/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/apexmedia.wordpress.com/321/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/apexmedia.wordpress.com/321/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/apexmedia.wordpress.com/321/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/apexmedia.wordpress.com/321/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/apexmedia.wordpress.com/321/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/apexmedia.wordpress.com/321/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/apexmedia.wordpress.com/321/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/apexmedia.wordpress.com/321/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/apexmedia.wordpress.com/321/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/apexmedia.wordpress.com/321/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/apexmedia.wordpress.com/321/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/apexmedia.wordpress.com/321/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/apexmedia.wordpress.com/321/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=learnola.com&amp;blog=4742992&amp;post=321&amp;subd=apexmedia&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://learnola.com/2008/11/24/beginners-java-tutorial-objects-and-classes/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2529d8f6ec74ee1afd5fd7dd213c6d5c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">apexmedia</media:title>
		</media:content>

		<media:content url="http://apexmedia.files.wordpress.com/2008/09/case-disks1.jpg" medium="image">
			<media:title type="html">case-disks1</media:title>
		</media:content>
	</item>
		<item>
		<title>Beginners Java Tutorial &#8211; Programming Part 1</title>
		<link>http://learnola.com/2008/11/20/beginners-java-tutorial-programming-part-1/</link>
		<comments>http://learnola.com/2008/11/20/beginners-java-tutorial-programming-part-1/#comments</comments>
		<pubDate>Thu, 20 Nov 2008 12:12:09 +0000</pubDate>
		<dc:creator>apexmedia</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Beginners Java Tutorial]]></category>
		<category><![CDATA[Java Programming]]></category>
		<category><![CDATA[learning Java]]></category>

		<guid isPermaLink="false">http://apexmedia.wordpress.com/?p=317</guid>
		<description><![CDATA[We also have some excellent Beginners Programming Java tutorials that use high quality narrated videos and practical working files to teach the fundamentals of programming in Java Beginners Java Tutorial Videos . Beginners Java Tutorial &#8211; Part 1 The Java language is currently one of the most widely used programming platforms, and can be used [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=learnola.com&amp;blog=4742992&amp;post=317&amp;subd=apexmedia&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-full wp-image-12" title="case-disks1" src="http://apexmedia.files.wordpress.com/2008/09/case-disks1.jpg?w=455" alt=""   />We also have some excellent Beginners Programming Java tutorials that use high quality narrated videos and practical working files to teach the fundamentals of programming in Java <a href="http://www.hyperteach.com/products/java-6-video-cd.htm">Beginners Java Tutorial Videos</a></p>
<div style="border-bottom:#a3c159 2px dashed;">.</div>
<h2>Beginners Java Tutorial &#8211; Part 1</h2>
<p>The Java language is currently one of the most widely used programming platforms, and can be used to build both desktop and Web applications. Java is used to develop with the Object Oriented technique, in which applications are characterised as a set of interacting &#8216;objects&#8217;, the objects being modules of code. This Java tutorial assumes no prior knowledge and aims to teach the basic fundamentals of Java Programming.</p>
<p>To start programming with Java, you will need:</p>
<ul>
<li>The <a title="download java" rel="nofollow" href="http://www.java.com/en/">Java Runtime Environment (JRE)</a> installed on your computer.</li>
<li>A Java IDE (Integrated Development Environment) such as <a title="download eclipse" rel="nofollow" href="http://www.eclipse.org/downloads/">Eclipse</a> or <a title="download netbeans" rel="nofollow" href="http://www.netbeans.org/downloads/">Netbeans</a>.</li>
</ul>
<p><em>Using an IDE will make your Java projects straightforward to manage and develop, and is therefore strongly recommended.</em></p>
<h3>Java compilation</h3>
<p>When you write code in a programming language, the compiler for the language generally translates your code into machine code for a particular system. This is code that can be run directly by the hardware of a computer with a specific operating system, architecture etc. The situation is slightly different with Java. When you create and compile your Java code, the end result is code that runs on the Java Virtual Machine, not code that runs directly on any actual machine. When the application is actually run, the JVM translates it into machine code for the specific computer it&#8217;s running on.</p>
<p>The process is as follows: when you write Java programs, your code is contained in .java files; when you compile and run these programs, .class files are generated &#8211; these contain bytecode, which runs on the JVM. The JVM code is then translated into machine code for the host machine. This means that when you create your Java applications, your compiled code can run on any operating system with Java installed, as it&#8217;s only translated into machine code when it&#8217;s actually run &#8211; this is one of the main advantages to using Java.</p>
<p>It isn&#8217;t necessary that you understand these concepts to get started with Java so don&#8217;t worry too much if it all seems confusing at this stage &#8211; it&#8217;ll begin to make more sense as you start to write programs.</p>
<h3>Your first program</h3>
<p>Once you&#8217;ve chosen and installed an IDE for Java, you&#8217;ll need to familiarise yourself with its interface; you may also need to perform setup tasks such as choosing a workspace location &#8211; see the instructions for your particular IDE. Within your chosen IDE, you&#8217;ll need to create a new project each time you want to start a new Java program. Each project will contain at least one package, with the package(s) containing your source .java files.</p>
<p><em>Different IDEs provide different levels of assistance, for example, when you create a new project/ class in Eclipse or Netbeans, the environment automatically creates a default package for your code.</em></p>
<p>Each .java file in the project will generally represent a &#8216;class&#8217; in your application, grouping together related code. Each of these &#8216;class declarations&#8217; provides a blueprint for a type of Object in your application. Again, the notion of Object will become clearer as your Java skills progress.</p>
<p>Every project will contain at least one class: the &#8216;Main&#8217; class. When your Java application is compiled and run, the first code that is executed is the code inside the &#8216;main method&#8217; &#8211; this code will be inside your Main class. Create a new Project in your IDE and name it MyFirstJava. If you&#8217;re using Netbeans choose Create Main class, entering myfirstjava.MyFirstJava as the name. If you&#8217;re using Eclipse create a new class inside your project and name it MyFirstJava. Select your MyFirstJava class and enter the following code (your IDE may have filled some of it in for you):</p>
<pre>//class declaration
public class MyFirstJava
{
//main method
	public static void main(String[] args)
	{
//code to be executed at runtime
		System.out.println("Well Hello There");
	}
}</pre>
<p><em>Note: If you&#8217;ve programmed with scripting languages before, you can think of methods as functions.</em></p>
<p>If you compile and run the program you should see the phrase written to the standard output console (this should be visible within your IDE interface). All that the code does is write a message out, as this is all that&#8217;s contained within the main method.</p>
<p>You really don&#8217;t need to understand all of what&#8217;s going on here, in fact it&#8217;s easier when you&#8217;re starting out to just treat it as a formula that works; you&#8217;ll understand the details later. Each time you create a new Java program just follow this pattern and enter your code within the main method to start with, and the rest will soon follow. Next <a href="http://learnola.com/2008/11/24/beginners-java-tutorial-objects-and-classes/">Java tutorial &#8211; Objects and Classes</a> .</p>
<br /> Tagged: Beginners Java Tutorial, Java Programming, learning Java <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/apexmedia.wordpress.com/317/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/apexmedia.wordpress.com/317/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/apexmedia.wordpress.com/317/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/apexmedia.wordpress.com/317/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/apexmedia.wordpress.com/317/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/apexmedia.wordpress.com/317/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/apexmedia.wordpress.com/317/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/apexmedia.wordpress.com/317/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/apexmedia.wordpress.com/317/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/apexmedia.wordpress.com/317/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/apexmedia.wordpress.com/317/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/apexmedia.wordpress.com/317/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/apexmedia.wordpress.com/317/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/apexmedia.wordpress.com/317/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=learnola.com&amp;blog=4742992&amp;post=317&amp;subd=apexmedia&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://learnola.com/2008/11/20/beginners-java-tutorial-programming-part-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2529d8f6ec74ee1afd5fd7dd213c6d5c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">apexmedia</media:title>
		</media:content>

		<media:content url="http://apexmedia.files.wordpress.com/2008/09/case-disks1.jpg" medium="image">
			<media:title type="html">case-disks1</media:title>
		</media:content>
	</item>
	</channel>
</rss>
