<?xml version="1.0" encoding="UTF-8"?><rss version="2.0">
<channel>
<title>Java</title>
<link>http://www.computersight.com/tags/Java</link>
<description>New posts about Java</description>
<item>
<title>Install Ubuntu Restricted Extras for Mp3 and DVD Playback in Ubuntu</title>
<link>http://www.computersight.com/Operating-Systems/Ubuntu/Install-Ubuntu-Restricted-Extras-for-Mp3-and-DVD-Playback-in-Ubuntu.437349</link>
<description>
<![CDATA[<p>Because Ubuntu and Linux is distributed as free software, to avoid potential legal problems for users of the operating system, Ubuntu comes without support for popular audio and video formats such as mp3, DVD and Flash.</p>
<p>However, luckily this is easily fixed by installing one package called Ubuntu-Restricted-Extras.  Installing this package will install Microsoft Fonts, Java Runtime Environment, Flash, LAME, MP3 and audio encoding and decoding as well as DVD playback.</p>
<p>To install them first you have to allow the extra repositories in Ubuntu, these are where the software are downloaded from and also will help keep your software updated in the future.  To do this on the top panel in Ubuntu click on System &amp;gt; Administration &amp;gt; Software Sources.  As shown below make sure the boxes are ticked, and choose your country from the "Download from:" box.</p>
<p><img src="http://images.stanzapub.com/readers/2009/01/04/screenshotsoftware-sources_1.jpg" alt="" /></p>
<p>(a screenshot of the sources window)</p>
<p>Next click on the Third Party Sources tab and make sure all the boxes are selected, then click close and from the dialog box click refresh, which will refresh the list all the available packages and programs now available to download and install.</p>
<p>Finally, click on System &amp;gt; Administration &amp;gt; Synaptic Package Manager.  As shown below you need to search for ubuntu-restricted-extras and selected it, then click apply and it should download and install.  Now you can listen to you MP3 files, watch DVD's and video files, and view flash flash files.</p>
<p><img src="http://images.stanzapub.com/readers/2009/01/04/screenshotsynaptic-package-manager_1.jpg" alt="" /></p>
<p>(A screenshot of the package manager)</p>
<p>As a final note, Kubuntu users should search for kubuntu-restricted-extras and Xubuntu users should search for xubuntu-restricted-extras</p><a href="http://www.pheedo.com/click.phdo?x=&u=http%3A%2F%2Fwww.computersight.com%2FOperating-Systems%2FUbuntu%2FInstall-Ubuntu-Restricted-Extras-for-Mp3-and-DVD-Playback-in-Ubuntu.437349"><img src="http://www.pheedo.com/img.phdo?x=&u=http%3A%2F%2Fwww.computersight.com%2FOperating-Systems%2FUbuntu%2FInstall-Ubuntu-Restricted-Extras-for-Mp3-and-DVD-Playback-in-Ubuntu.437349" border="0"/></a>]]></description>
<pubDate>Mon, 05 Jan 2009 08:35:49 PST</pubDate></item>
<item>
<title>The Worlds Greatest Program, Hello World!</title>
<link>http://www.computersight.com/Software/The-Worlds-Greatest-Program-Hello-World.403511</link>
<description>
<![CDATA[<p>"Hello World!", this program is written in every language as one of the most basic programs so almost all beginners can do it, I will show it in C++.</p>
<p>Here is it dissected, "//" means the rest of that line is commented out so the compiler doesn't see it /* */ comments out all the code in between them</p>
<p>#include // #includes, does as it says it includes the file in the "&amp;lt; &amp;gt;". The file 'iostream.h' aka Input Output stream is need for the further lines of code</p>
<p>using namespace std;// basically a way to type less, it includes the namespace, basically a library of functions. With out this you would need to write std::cout instead of cout</p>
<p>int main()// starts the main function, this is where all C++ programs start</p>
<p>{// shows the start of a function</p>
<p>cout &amp;lt;&amp;lt; Hello World! &amp;lt;&amp;lt; endl;// Cout aka Computer Output, is a simply writes to the console, it write what is after the &amp;lt;&amp;lt;, if its next it needs to be in  a "". (endl simply ends the line)</p>
<p>return 0;//simply exits out of the function with the return value of 0</p>
<p>} // shows the end of a function</p>
<p>/*</p>
<p>depending on your compiler the program may open and close so fast that you don't see it, to fix this add</p>
<p>"#include " to the top of the file and "system("PAUSE");" one the line before "return 0;"</p>
<p>this will stop the program from cloding till you hit a key */</p><a href="http://www.pheedo.com/click.phdo?x=&u=http%3A%2F%2Fwww.computersight.com%2FSoftware%2FThe-Worlds-Greatest-Program-Hello-World.403511"><img src="http://www.pheedo.com/img.phdo?x=&u=http%3A%2F%2Fwww.computersight.com%2FSoftware%2FThe-Worlds-Greatest-Program-Hello-World.403511" border="0"/></a>]]></description>
<pubDate>Fri, 19 Dec 2008 01:46:26 PST</pubDate></item>
<item>
<title>Is Visual Basic the Best Language?</title>
<link>http://www.computersight.com/Programming/Visual-Basic/Is-Visual-Basic-the-Best-Language.347771</link>
<description>
<![CDATA[<p>Visual Basic allows the programmer to create the user interface first, and then add the code as needed to make the interface work. In fact, the majority of the interface is already done for you in the Visual Basic compiler. As a programmer you will only need to tweak the environment and then add the code in the back end to have the interface perform exactly as you would like, also Visual Basic has a large library of pre-made functions that is easily accessible. This allows the programmer to quickly create Windows based applications with a minimal amount of effort.</p>
<p>FORTRAN and Visual Basic, although they are both high level languages, differ greatly in their usage. As stated previously Visual Basic is great for quickly building an application that can do almost anything you need it to do. FORTRAN, on the other hand, is more of a scientific language. FORTRAN is short for &amp;lsquo;formula translator' and is used for formula solving applications.</p>
<p>A large advantage Java has over Visual Basic is that it can perform on virtually any system (Windows (any version), MacOS or UNIX), while Visual Basic is the master of Windows. The reason for this is because Java requires the Java Virtual Machine to be downloaded and installed on any machine Java is installed on. This download does cause certain security issues with access to Java applications. Java does have certain features (the Sandlot security model, etc.) that aid in protecting it but are not tamperproof. Both Java and Visual Basic are excellent languages for development and a developer should know exactly what his network structure is before choosing which language he wishes to use.</p>
<p>Many independent programmers prefer Perl over Visual Basic. They like the ease of use, the cost (free), and many believe a better support base (via online resources versus Microsoft support, which also costs money). But no one can deny the Visual Basic GUI design tools and useful wizards. Regardless of what programmers want they are usually bound by whatever their company uses. In most cases if the company has invested in to Visual Basic then that is what will be used. Also, the actual GUI for Perl is not the most attractive.</p>
<h3>Visual Basic Support and Tools<br /></h3>
<p>There are more tools for Visual Basic than I can name here, but I will give a few examples.<br />&amp;bull;	Sonic Alpha Style Control aids in the look and feel of your GUI.<br />&amp;bull;	Sonic Click - Mega Button Control gives your buttons a web look<br />&amp;bull;	VBScodePrint allows more flexibility in the look of the actual code<br />&amp;bull;	TurboVb Mini Apps allows a person to register and unregister components from explorer</p>
<p>These tools can range to $0 - $150 or more. Visual Basic has more tools created for it than any other programming language. Search the Internet and you will find several free applications you will find useful for your programming experience.</p>
<p>Visual Basic has two main ways to receive support. The expensive and time consuming way is by contacting Microsoft. The more common way is to look for help via the Internet. There are several web sites dedicated to the programmer who is in need of some help. They are usually quicker and always free.</p><a href="http://www.pheedo.com/click.phdo?x=&u=http%3A%2F%2Fwww.computersight.com%2FProgramming%2FVisual-Basic%2FIs-Visual-Basic-the-Best-Language.347771"><img src="http://www.pheedo.com/img.phdo?x=&u=http%3A%2F%2Fwww.computersight.com%2FProgramming%2FVisual-Basic%2FIs-Visual-Basic-the-Best-Language.347771" border="0"/></a>]]></description>
<pubDate>Mon, 17 Nov 2008 03:39:28 PST</pubDate></item>
<item>
<title>How to Make an Analog Clock for Your Website</title>
<link>http://www.computersight.com/Programming/Java/How-to-Make-an-Analog-Clock-for-Your-Website.283309</link>
<description>
<![CDATA[<p>First you will need to make sure you have Java installed on your computer. If you don't you can download it from <a href="http://www.java.sun.com" target="_blank">http://www.java.sun.com</a>.</p>
<p>1.    Open a text editor. Any simple editor will work, Notepad, TextEdit, whatever. Just make sure when you save, to save it as Plain Text, not Rich Text Format. Save this file as "Clock.java" on your Desktop in a folder called "Clock".</p>
<p>2.    Let's set up an applet. For this tutorial, we will use a JApplet, from Java's Swing library. Type the following code into your text editor (new additions will appear in bold):<br /></p>
<blockquote>import javax.swing.JApplet;<br /></blockquote>
<blockquote>public class Clock extends JApplet {<br /></blockquote>
<p>public void init() {<br /><br /> }<br /> }</p>
<p><br />3.    That&amp;rsquo;s all we need to create a &amp;ldquo;bare bones&amp;rdquo; applet. The import statement at the top tells Java that we will need the JApplet class from the javax.swing library. The next line creates a new Class called Clock, which will be a JApplet (a program that is run within a browser window). The init() method is what the program will do when the program is started.<br /><br />Now let&amp;rsquo;s set this applet up with a Thread. A Thread is a way to perform a set of actions over and over without freezing the rest of the program (in this case, updating the time).<br /><br />import javax.swing.JApplet;<br />import java.awt.*;<br /><br />public class Clock extends JApplet implements Runnable {<br /> public void init() {<br /><br /> }<br /><br /> public void run() {<br /> while (true) {<br /> try {<br /> Thread.sleep(1000);<br /> } catch (Exception e) {<br /> }<br /> }<br /> }<br /> }<br /><br />4.    Let&amp;rsquo;s look at this code. First we imported the java.awt package (the .* extension tell the program to include all of the classes in the library). Next we added &amp;ldquo;implements Runnable&amp;rdquo; to the class declaration, which means that the class will be running a Thread.<br /><br />The next section is the run method. When a Thread is started, this method will be executed. Right now, our run method will loop until the program is exited (while true is equal to true) and each time through the loop it will pause the Thread for 1 second (1000 milliseconds).<br /><br />Now we should set up a Thread. I called my Thread &amp;ldquo;counter&amp;rdquo;, but you can name it whatever you want. These commands are fairly self-explanatory.<br /><br />import javax.swing.JApplet;<br />import java.awt.*;<br /><br />public class Clock extends JApplet implements Runnable {<br /> Thread counter = new Thread(this);<br /><br /> public void init() {<br />counter.start();<br /> }<br /><br /> public void run() {<br /> while (true) {<br /> try {<br /> Thread.sleep(1000);<br /> } catch (Exception e) {<br /> }<br /> }<br /> }<br /> }<br /><br />5.    Now we can get to the actual point of our program, to tell time. First we&amp;rsquo;ll get the GregorianCalendar class and use it to find out the current time in EST. I added variables to the program for hours, minutes, and seconds, to be stored as integers, which are called &amp;ldquo;int&amp;rdquo; in Java. Finally, in our while loop, we will add a long section to increment the time variables. If you don&amp;rsquo;t understand this section it&amp;rsquo;s OK for now.<br /><br />import javax.swing.JApplet;<br />import java.awt.*;<br />import java.util.*;<br /><br />public class Clock extends JApplet implements Runnable {<br /> int hours, minutes, seconds;<br /> Thread counter = new Thread(this);<br /><br /> public void init() {<br />Calendar calendar = new GregorianCalendar(TimeZone.getTimeZone("EST"));<br /> hours = calendar.get(Calendar.HOUR);<br /> minutes = calendar.get(Calendar.MINUTE);<br /> seconds = calendar.get(Calendar.SECOND);<br /> counter.start();<br /> }<br /><br /> public void run() {<br /> while (true) {<br /> if (seconds &amp;lt; 60)<br /> seconds++;<br /> else {<br /> seconds = 0;<br /> if (minutes &amp;lt; 60)<br /> minutes++;<br /> else {<br /> minutes = 0;<br /> if (hours &amp;lt; 12)<br /> hours++;<br /> else<br /> hours = 1;<br /> }<br /> }<br />repaint();<br />try {<br /> Thread.sleep(1000);<br /> } catch (Exception e) {<br /> }<br /> }<br /> }<br /> }<br />6.    Now we have our time program essentially all done. All that needs to be done now is to draw the clock itself. Go to the bottom of your text file and just above the final &amp;lsquo;}&amp;rsquo;, type in this code:<br /><br /> public void paint(Graphics g) {<br /> Graphics2D g2 = (Graphics2D) g;<br /> g2.setColor(Color.white);<br /> g2.fillRect(0, 0, getWidth(), getHeight());<br /> g2.setColor(Color.darkGray);<br /> g2.fillOval(0, 0, getWidth(), getHeight());<br /> g2.setColor(Color.black);<br /> for (int i = 1; i &amp;lt;= 12; i++) {<br /> g.drawString("" + i, getWidth() / 2 + (int)(Math.cos(i * (Math.PI / 6) - Math.PI / 2) * (getWidth() / 2 - 15)), getHeight() / 2 + (int)(Math.sin(i * (Math.PI / 6) - Math.PI / 2) * (getHeight() / 2 - 15)));<br /> }<br /> int radius = getWidth() / 2 - 10;<br /> double divideBy = (30 / Math.PI);<br /> g2.drawLine(getWidth() / 2 + (int)(Math.cos(seconds / divideBy - Math.PI / 2) * radius), getHeight() / 2 + (int)(Math.sin(seconds / divideBy - Math.PI / 2) * radius), getWidth() / 2, getHeight() / 2);<br /> BasicStroke stroke = new BasicStroke(4);<br /> g2.setStroke(stroke);<br /> radius = getWidth() / 2 - 50;<br /> g2.drawLine(getWidth() / 2 + (int)(Math.cos(minutes / divideBy - Math.PI / 2) * radius), getHeight() / 2 + (int)(Math.sin(minutes / divideBy - Math.PI / 2) * radius), getWidth() / 2, getHeight() / 2);<br /> stroke = new BasicStroke(8);<br /> g2.setStroke(stroke);<br /> divideBy = (6 / Math.PI);<br /> radius = getWidth() / 2 - 80;<br /> g2.drawLine(getWidth() / 2 + (int)(Math.cos(hours / divideBy - Math.PI / 2) * radius), getHeight() / 2 + (int)(Math.sin(hours / divideBy - Math.PI / 2) * radius), getWidth() / 2, getHeight() / 2);<br /> g2.fillOval(getWidth() / 2 - 10, getHeight() / 2 - 10, 20, 20);<br /> g2.drawOval(0, 0, getWidth(), getHeight());<br /> }</p>
<p>Now you need to compile the program. Open your command line (Command Prompt on Windows, Terminal on Mac).  Type "cd Desktop/Clock" and hit enter. Note, this is the Mac command; if you are using Windows, switch the '/' to a ''. Next type "javac Clock.java". If your code is copied correctly, it will just go back to prompting for input and there will be a new file in the folder called "Clock.class". Now upload this .class file to wherever your website is, and to embed it in one of your pages, use this code:</p>
<p>There you go. You have a clock applet for your site!</p><a href="http://www.pheedo.com/click.phdo?x=&u=http%3A%2F%2Fwww.computersight.com%2FProgramming%2FJava%2FHow-to-Make-an-Analog-Clock-for-Your-Website.283309"><img src="http://www.pheedo.com/img.phdo?x=&u=http%3A%2F%2Fwww.computersight.com%2FProgramming%2FJava%2FHow-to-Make-an-Analog-Clock-for-Your-Website.283309" border="0"/></a>]]></description>
<pubDate>Fri, 03 Oct 2008 16:14:45 PST</pubDate></item>
<item>
<title>Solidworks Tutorial: How to Draw Circle and Filleted Arc</title>
<link>http://www.computersight.com/Software/Solidworks-Tutorial-How-to-Draw-Circle-and-Filleted-Arc.255169</link>
<description>
<![CDATA[<p>In the first article of my tutorial set, I tought you how to draw linear objects. Those were simply lines and rectangular, that is, the main elements of drawing. In this article, I aim to teach you curves and the simplest closed curve, a circle.</p>
<h3>How to Draw a Circle<br /></h3>
<p>As a mathematical description, circle is a combination of points with the same length from a fixed point. To draw a circle, two things we need. They are the coordinate of center of the circle and radius or diameter of it. Let's now draw our first circle by Solidworks. Let's draw a circle with a center of origin and a radius of 20 mm.</p>
<ol>
<li>Click the sketch button to define a plane on which you will draw. Since our drawing is 2D, any plane can be chosen. I choose top plane as a reference plane.</li>
<li>Click the circle button on the toolbar and choose origin as the center point of the circle. Afterthat, drag the circle to the out of the page.</li>
<li>By clicking "smart dimension" button , dimension the radius of circle. Since the radius is 20 mm, specify diameter as 40 mm.</li>
</ol>
<p><img src="http://images.stanzapub.com/readers/2008/09/15/sw1_2.jpg" alt="" /></p>
<h3>How to Draw Filleted Arcs</h3>
<p>To draw filleted arcs, we first need a corner of two intersecting lines. As an example, we will filet one corner of 40x40 mm square. Lets first draw the square by using rectangular button on the toolbar.</p>
<p><img src="http://images.stanzapub.com/readers/2008/09/15/sw2_1.jpg" alt="" /></p>
<ol>
<li>Click the fillet button on the toolbar.</li>
<li>Enter the radius of fillet as 5 mm into the fillet parameters space.</li>
<li>Choose the corner point which you want to fillet. Be careful here, you should select the point not the sides you want to fillet. After that, Solidworks automatically dimension the filleted arc. Here is the result.</li>
</ol>
<p><img src="http://images.stanzapub.com/readers/2008/09/15/sw3_1.jpg" alt="" /></p>
<p><img src="http://images.stanzapub.com/readers/2008/09/15/sw1_1.jpg" alt="" /></p><a href="http://www.pheedo.com/click.phdo?x=&u=http%3A%2F%2Fwww.computersight.com%2FSoftware%2FSolidworks-Tutorial-How-to-Draw-Circle-and-Filleted-Arc.255169"><img src="http://www.pheedo.com/img.phdo?x=&u=http%3A%2F%2Fwww.computersight.com%2FSoftware%2FSolidworks-Tutorial-How-to-Draw-Circle-and-Filleted-Arc.255169" border="0"/></a>]]></description>
<pubDate>Tue, 16 Sep 2008 03:12:21 PST</pubDate></item>
<item>
<title>Why Solidworks?</title>
<link>http://www.computersight.com/Programming/Why-Solidworks.238675</link>
<description>
<![CDATA[<p>Today, engineers and engineering students use many software programs while designing new constructions, mechanisms and systems. Of all those software programs; Autocad, Solidworks, Unigraphics, Catia and Proengineering are the most popular and preferred programs. Autocad is usually used for 2D design. However, others are for 3D design. I've started using Solidworks after one year experience in Autocad. I realized that Autocad sometimes doesn't meet my requirements. I discovered Solidworks and what I would do with the assistance of this program.<br /><br />Why solidworks? Because it is very easy to use. Eveything is clear in Solidworks. If you know English and have a little computer knowledge and technical information, you can easily learn how to use Solidworks wtihout needing any additional source like books and tutorials. It is very easy to understand the fundementals of SW.<br /><br />Other plausible reason is that there are many Solidworks books in Bookstores. One can find many resources written in different languages. For me, it is easy to find such sources written both in English and my native language Turkish. Solidworks have been given as two-semester course in most of European and American universities. <br /><br />Designing starts with 2D in Solidworks. Above all, you should have a knowledge of drawing in 2D. You should be capable of making 2D sketches. You should be capable of forming the main 2D construction of solid systems. Rest is very simple because it goes on with simple extrusion, hole making, cutting, lofting and revolving processes.<br /><br />Another advantage of Solidworks is that it works well with all versions of Windows operating system. The last version,&amp;nbsp; SW 2008, is installed and worked on Vista after loading Service Pack of Vista. Without Service Pack, it doesn't run on your system.<br /><br />To learn how to use Solidworks and how to design systems or just making drawings for fun, follow my tutorial set. My next article will be about simple 3D drawings. In the next articles, you should learn how to draw cylinders, rectangular prisms and cubes with very different dimensions.<br /><br />In a nutshell, Solidworks is a good way to explain the things in your mind with simple lines and curves.</p><a href="http://www.pheedo.com/click.phdo?x=&u=http%3A%2F%2Fwww.computersight.com%2FProgramming%2FWhy-Solidworks.238675"><img src="http://www.pheedo.com/img.phdo?x=&u=http%3A%2F%2Fwww.computersight.com%2FProgramming%2FWhy-Solidworks.238675" border="0"/></a>]]></description>
<pubDate>Tue, 02 Sep 2008 09:54:10 PST</pubDate></item>
<item>
<title>Lets Learn C : Printing Strings on to the Screen</title>
<link>http://www.computersight.com/Programming/Lets-Learn-C--Printing-Strings-on-to-the-Screen.225265</link>
<description>
<![CDATA[<p>Here is the first article of my tutorial set. I aim to teach you the basics of C. In this first lesson, I am going to teach you how to output a series of strings on to terminal screen of C program.</p>
<p>Virtually every program code has inputs and outputs. Before compiling a source code, programs generally request an input from the user and then output it to the screen after compiling if the program is well designed and there is no error inside it. Usually, as the program becomes more complicated, error possibility increases. A good software expert easily realizes where the code has faults and corrects it. Since our first code will be very small and very simple, we will not face with any error.</p>
<p>Before starting to write code, we initially have a compiler which is going to evaluate our code. I use Dev C for this. There are many other compilers which run on different platforms like Unix, Linux and Windows.</p>
<p>In this project, we will output the names of  the subprograms of Triond on to C terminal screen. This is the simplest algorithm since there is no input in this example. Let's start writing our code step by step.</p>
<p>Step 1: Open the File from the menu bar of C software and save as the blank page Project1. This yields a file with an extension of cpp.</p>
<p>Step 2: Describe the name and aim of the programs. To do so, we use comments. Comments are ignored by the compiler. For commenting, we use some special scripts like double slash  or  slash-asterisk character .</p>
<p>If we use a single line comment, double slash is enough. However, if our comment is placed more than one line, we use double slash for each line or take the commented part between  slash-asterisk and asterisk-slash characters .</p>
<p>Step 3:  C needs library files which define what the input and output functions are and what they do when they are used in a code. Iostream is the library file of input and output function.</p>
<p>Before the name of library files, we use a special character,  preprocessor directive character. Include is used before the name of every library file and such file names are placed mathematical comparison characters.</p>
<p>Step 4:  Every C code uses functions. The default function is main. Main function is the first function compiled by the programs. This function usually calls other functions. Before the name of function, we specify which type of output our code returns. In our program, we think that it returns to integer and use int. After the function name, we use parantheses. In this example, there will be nothing between parantheses but in more complicated programs, there may be parameter names and it's types or definitions. We place our statements between left brace  and  right brace.</p>
<p>Step 5:  To print on to the screen,we use cout function. We simply place our string inside  double quote  characters. Every statement inside the functions ends with a special semicolon character.</p>
<p>Step 6:  To check the validity, we use return function.In this simple example, it returns to 0.</p>
<p><a href="http://clesson1.blogspot.com/" target="_blank">Click here for the code</a></p><a href="http://www.pheedo.com/click.phdo?x=&u=http%3A%2F%2Fwww.computersight.com%2FProgramming%2FLets-Learn-C--Printing-Strings-on-to-the-Screen.225265"><img src="http://www.pheedo.com/img.phdo?x=&u=http%3A%2F%2Fwww.computersight.com%2FProgramming%2FLets-Learn-C--Printing-Strings-on-to-the-Screen.225265" border="0"/></a>]]></description>
<pubDate>Sun, 24 Aug 2008 10:02:41 PST</pubDate></item>
<item>
<title>The Basics of Java Programming 2</title>
<link>http://www.computersight.com/Programming/Java/The-Basics-of-Java-Programming-2.221003</link>
<description>
<![CDATA[<h3><strong>Last Time...</strong></h3>
<p>Last time we covered the very basic syntax of a Java program and how to print text into a command-line box. Expanding on that this week, you will learn how to use variables which are a VERY important component to a program.</p>
<h3>Variables</h3>
<p>A variable is like a box. You are able to put different objects into a box, just like you can put different data into a variable. You can also change what is in the box at whatever time you want. This is just like a variable. It's data can be changed, even while the program is running.</p>
<p>So to be clear, a variable can hold a piece of data, and only one. If you wanted to store multiple bits of data, you would use an array. We will get to arrays later on, for now, know that variables store data and can be changed.</p>
<p>Now, onto the use of a variable. To declare a variable and set its value, you use the following syntax:</p>
<p><strong>public class Variables {<br />&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public static void main(String args[]){<br />&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; int thisIsMyVariable = 0;<br />&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }<br />}</strong></p>
<p>This is how you declare an integer variable, which if you remember from the previous tutorial, is a number. To create a string variable, you replace "int" with "String". But be careful when using strings. You must remember to place the whole string in quotation marks or you will return an error.</p>
<p>Now that we have our variable, lets try displaying it in your command-line box:</p>
<p><strong>public class Variables {<br /> &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public static void main(String args[]){<br /> &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; int thisIsMyVariable = 0;<br />&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.out.println(thisIsMyVariable);<br /> &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }<br /> }</strong></p>
<p>You will notice that you do not place quotation marks around the variable name when printing it, if you did, you would get a result of: "thisIsMyVariable" instead of the value the variable contains. Once you've tried this, change the value of the variable to any number you like. Don't make it too large though, try to keep it under 65,000.</p>
<p>As an extra excercise, try changing the datatype of the variable to a String and edit its value.</p>
<h3>Calculations<br /></h3>
<p>Once you've had a bit of a play with that, we can move onto calculations. We can use variables and mathematical signs to add, subtract, multiply and divide numbers. We can also use other symbols to assign values to variables and check for certain things. Here is a list of all the symbols and what they can be used for:</p>
<p>+ &amp;nbsp;&amp;nbsp; Used for adding two values together<br />-&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Used for subtracting two values<br />*&amp;nbsp;&amp;nbsp;&amp;nbsp; Used for multiplying two values<br />/&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Used for dividing two values<br />=&amp;nbsp;&amp;nbsp;&amp;nbsp; Used for assigning a value<br />==&amp;nbsp; Used for checking if a value is equal to another value<br />&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Used for checking if a value is greater than another value<br />&amp;lt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Used for checking if a value is less than another value<br />&amp;gt;=&amp;nbsp; Used for checking if a value is greater than or equal to another value<br />&amp;lt;=&amp;nbsp; Used for checking if a value is less than or equal to another value<br />++&amp;nbsp; Used for adding 1 to a value<br />--&amp;nbsp;&amp;nbsp;&amp;nbsp; Used for subtracting 1 from a value</p>
<p>In this next example, I will demonstrate how these can be used in a program. Read through the code and try to follow what is happening:</p>
<p><strong>public class Variables {<br />&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public static void main(String args[]) {<br />&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; int var1 = 0;<br />&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; int var2 = 5;<br />&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; int var3 = 10;<br />&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; <br />&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var1 = (var2 + var3) / var2 * 2;<br />&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.out.println(var1);<br />&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var1++;<br />&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.out.println(var1);<br />&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var2++;<br />&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var3--;<br />&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var1 = var2 * var3;</strong><strong>&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; <br />&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.out.println(var1);<br />&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }<br />}</strong></p>
<p>I have used some random numbers and used a combination of symbols to do various calculations and print me the result as it goes. Have a go yourself and try changing around the numbers and calculations.</p>
<h3>Next time...</h3>
<p>Now that we've covered variables and performing calculations, we will move onto "if and then" statements, loops and using variables in a more complex and useful way. I hope you enjoyed learning more about Java. Check out the next tutorial for the next lesson.</p><a href="http://www.pheedo.com/click.phdo?x=&u=http%3A%2F%2Fwww.computersight.com%2FProgramming%2FJava%2FThe-Basics-of-Java-Programming-2.221003"><img src="http://www.pheedo.com/img.phdo?x=&u=http%3A%2F%2Fwww.computersight.com%2FProgramming%2FJava%2FThe-Basics-of-Java-Programming-2.221003" border="0"/></a>]]></description>
<pubDate>Thu, 21 Aug 2008 08:38:56 PST</pubDate></item>
<item>
<title>Java Final Keyword</title>
<link>http://www.computersight.com/Programming/Java/Java-Final-Keyword.219303</link>
<description>
<![CDATA[<h3>Final keyword</h3>
<p>A simple tutorial on the basics of java &amp;ldquo;final&amp;rdquo; keyword. This is very useful for java learners.</p>
<p>The final keyword is used to declare the final classes, final methods and final variables.</p>
<h3>final class:</h3>
<p>If the class is declared as a final, you can not extend this class. The purpose of this, nobody can change your functionality with overriding the methods.</p>
<p>We can avoid the sub-classing using final keyword.  You can avoid the sub-classing using private constructor also, but you can not create the Instance out-side of that class.</p>
<p>Declaring the final class:</p>
<p>public <strong>final</strong> classname{</p>
<p>}</p>
<p>There are some final classes in the Java also.  Some of them are:</p>
<p>String <br /><br /> StringBuilder</p>
<p>Integer</p>
<p><strong>final</strong> method:</p>
<p>If the method is declared as final, you can not override this method. The purpose of this, if you extend the class also you can not override the final methods.</p>
<p>Declaring the final methods:</p>
<p>Public <strong>final</strong> return-type methodname() {</p>
<p>}</p>
<p><strong>final</strong> variable:</p>
<p>If the variable is declared as final, you can not change the value of that variable. Whenever you need the constant values like pie, you can use the final variables.</p>
<p>Declaring the final variable:</p>
<p>public <strong>final</strong> float pie = 3.44f;</p>
<p>The pie variable value is constant, because of it's final variable. We can not change the value of pie variable once it is initialized.</p><a href="http://www.pheedo.com/click.phdo?x=&u=http%3A%2F%2Fwww.computersight.com%2FProgramming%2FJava%2FJava-Final-Keyword.219303"><img src="http://www.pheedo.com/img.phdo?x=&u=http%3A%2F%2Fwww.computersight.com%2FProgramming%2FJava%2FJava-Final-Keyword.219303" border="0"/></a>]]></description>
<pubDate>Thu, 21 Aug 2008 04:21:45 PST</pubDate></item>
<item>
<title>The Basics of Java Programming [1]</title>
<link>http://www.computersight.com/Programming/Java/The-Basics-of-Java-Programming-1.218103</link>
<description>
<![CDATA[<h3>Getting Started</h3>
<p>Before we begin, you are going to need a few things to work with Java. These are:</p>
<ul>
<li><a href="http://java.sun.com/javase/downloads/index.jsp" target="_blank">The Java Development Kit </a><br /></li>
<li><a href="http://www.eclipse.org/downloads/" target="_blank">A Java Integrated Development Environment</a><br /></li>
<li>A ready-to-learn attitude</li>
</ul>
<p>Okay, once you have all these things installed and setup, you can proceed into some java programming.</p>
<p>Note: Any words in italics is one which you should familiarise yourself with. I have included the definitions of these at the end.</p>
<h3>The Basics<strong><br /></strong></h3>
<p>Java is a very easy-to-use language and very user-friendly, especially if you have programmed in other languages before. If you haven't, don't stress, this tutorial will teach you step by step. To begin, lets go over the basic syntax of a java program.</p>
<p>Here is a simple program which prints "Hello World" into a command-line box:</p>
<p><strong>public class HelloWorld {<br />&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public static void main(String args[]) {<br />&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.out.println("Hello World");<br />&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }</strong><strong><br />}</strong></p>
<p>Let's look at this step by step. The first line:</p>
<p><strong>public class HelloWorld {</strong></p>
<p>The word "public" refers to the level of access of the program. Public is used to allow other programs and classes to interact with it. "class" begins the definition for a class which we have named "HelloWorld". It isn't important right now to know all about classes, just know our class is created named HelloWorld and is signified by the curly bracket ("{" and "}"). These brackets define where a class, method, function etc begin and end. Lets move onto the next line:</p>
<p><strong>public static void main(String args[]) {</strong></p>
<p>Once again, "public" is used as an access level identifier. "static" methods are used for methods such as computing mathematical equations and other processing in which other objects aren't used. Don't worry yourself too much with this, all you need to know is we are going to use it in our programs. As your Java knowledge expands, you will understand more and more about these types of things. An important thing to know is that all Java programs must have a "main" method. This method is the entry point for your program and will be used to activate other methods required by your program. The main method accepts a single argument: An array of elements of datatype String. Each string in the array is called a command-line arugment which lets users affect the application without recompiling it. Again, do not worry too much about this, just know that this line of code is necessary for Java programs. The last line of code is what actually prints the text "Hello World":</p>
<p><strong>System.out.println("Hello World");</strong></p>
<p>This line of code uses the "System" class from the core library to display the text "Hello World", hence the "out.println" which basically means "Output and Print Line 'Hello World'". Any text within quotation marks (i.e. "Hello World") is a string and can contain letters, numbers and some symbols. You will notice the semi-colon after the bracket, this is tell the computer where that specific line of code ends. This is required after every line of code except those which end in a curly bracket or a few other exceptions which are unimportant for the time being.</p>
<p>Now that you know exactly what this code means, you can try it yourself. Open your IDE (hopefully Eclipse) and start a new java file. Type in or copy and paste the following code and try compiling and running your program.</p>
<p><strong>public class HelloWorld {<br />&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public static void main(String args[]) {<br />&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.out.println("Hello World");<br />&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }<br /> }</strong></p>
<p><strong>NOTE: When saving the program, be sure to name it EXACTLY as you've named your class. Otherwise your program will not work. For my program, I would call it: "HelloWorld.java".</strong></p>
<p>Hopefully you receive a black command-line box with the text: "Hello World". If so, congratulations! You have just written your first Java program! My next tutorial will cover variables and simple mathematical operations. I hope you enjoyed learning about the Java language and see my next tutorial for more Java fun.</p>
<h3>Glossary</h3>
<p><strong>Java Development Kit (JDK):</strong> This is a necessary Java kit needed for compiling and running java programs.</p>
<p><strong>Integrated Development Environment (IDE):</strong> This is a text editor which usually has a compiler built into it, used for programming in Java and a range of other languages.</p>
<p><strong>Syntax:</strong> The syntax of a program is the basic "template" or "layout" it requires to understand what you're telling it to do.</p>
<p><strong>Public:</strong> Public refers to the level of access of that class, method etc.</p>
<p><strong>Method:</strong> A method is a set of grouped instructions which can be called to run at any time within the program.</p>
<p><strong>Function:</strong> A function is similar to a method but a function uses values you can send to it to return a different value after doing the appropriate processing or calculations.</p>
<p><strong>Datatype:</strong> Datatype is a word used to define variables etc as a certain type. i.e. A string has a text datatype and can accept letters, numbers and some symbols. An integer on the other hand, can only contain numbers.</p>
<p><strong>String: </strong>A datatype for text, see above.</p><a href="http://www.pheedo.com/click.phdo?x=&u=http%3A%2F%2Fwww.computersight.com%2FProgramming%2FJava%2FThe-Basics-of-Java-Programming-1.218103"><img src="http://www.pheedo.com/img.phdo?x=&u=http%3A%2F%2Fwww.computersight.com%2FProgramming%2FJava%2FThe-Basics-of-Java-Programming-1.218103" border="0"/></a>]]></description>
<pubDate>Wed, 20 Aug 2008 06:03:06 PST</pubDate></item>
</channel>
</rss>
