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

<channel>
	<title>Building Blocks Java</title>
	<atom:link href="http://buildingblocksjava.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://buildingblocksjava.com</link>
	<description>JAVA tips and tutorials</description>
	<lastBuildDate>Wed, 29 Jul 2009 13:48:12 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Acknowledgements</title>
		<link>http://buildingblocksjava.com/acknowledgements/</link>
		<comments>http://buildingblocksjava.com/acknowledgements/#comments</comments>
		<pubDate>Wed, 29 Jul 2009 13:48:12 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://buildingblocksjava.com/?p=84</guid>
		<description><![CDATA[Noone ever truly writes a book alone.  This tutorial relies heavily on Brian Kernighan and Dennis Ritchie&#8217;s The C Programming Language, one of the alltime classics of computer language manuals.
The presentations at the first Java Day in New York City were crucial to getting my understanding of Java off the ground, especially those of [...]]]></description>
			<content:encoded><![CDATA[<p>Noone ever truly writes a book alone.  This tutorial relies heavily on Brian Kernighan and Dennis Ritchie&#8217;s <cite>The C Programming Language</cite>, one of the alltime classics of computer language manuals.</p>
<p>The presentations at the first Java Day in New York City were crucial to getting my understanding of Java off the ground, especially those of Bill Joy and Frank Greco.</p>
<p>The eventtutor applet, flying lines applet and Mondrian applets are taken in spirit if not in code from Dave Mark and Cartwright Reed&#8217;s <cite>Macintosh Programming Primer</cite>.</p>
<p>Finally I&#8217;d like to thank Olivia Whiteman, Dave Fisco, Tim Arnold and all the other Java Invaders for putting together forums in which I could learn more Java.</p>
]]></content:encoded>
			<wfw:commentRss>http://buildingblocksjava.com/acknowledgements/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Part 1: Why Java&#8217;s Cool</title>
		<link>http://buildingblocksjava.com/part-1-why-javas-cool/</link>
		<comments>http://buildingblocksjava.com/part-1-why-javas-cool/#comments</comments>
		<pubDate>Wed, 29 Jul 2009 13:46:23 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://buildingblocksjava.com/part-1-why-javas-cool/</guid>
		<description><![CDATA[Java has caused more excitement  than any development on the Internet since Mosaic. Everyone, it seems, is talking about it.  Unfortunately very few people seem to know anything about it.  This tutorial is designed to change that.
People are excited about  Java because of what it lets them do.  Java was [...]]]></description>
			<content:encoded><![CDATA[<p>Java has caused more excitement  than any development on the Internet since Mosaic. Everyone, it seems, is talking about it.  Unfortunately very few people seem to know anything about it.  This tutorial is designed to change that.</p>
<p>People are excited about  Java because of what it lets them do.  Java was the first way to include inline sound and animation in a web page.  Java also lets users  interact with a web page.  Instead of just reading it and perhaps filling out a form, users can now play games, calculate spreadsheets, chat in realtime, get continuously updated data and much, much more.</p>
<p>Here are just a few of the many things Java can do for a web page:</p>
<ul>
<li>Inline sounds that play in realtime whenever a user loads a page</li>
<li>Music that plays in the background on a page</li>
<li>Cartoon style animations</li>
<li>Realtime video</li>
<li>Multiplayer interactive games</li>
</ul>
<p>However Java is more than just a web browser with special features.   All of these features can be integrated into browsers in other ways. Although HotJava was the first browser to include inline sound and animation, Microsoft&#8217;s Internet Explorer 2.0 and Netscape Navigator 2.0 support these features in several different ways.  What makes Java special?</p>
<p>Java is a programming language for distributed applications.   It doesn&#8217;t just allow you to add  new types of content to your  pages like Netscape and Internet Explorer do.  Rather it lets you add both the content and the code necessary to interact with that content. You no longer need to wait for the next release of a browser  that supports your  preferred image format or special game protocol.   With Java you send browsers both the content and the program necessary to view this content at the same time!</p>
<p>Let&#8217;s think about what this means for a minute.  Previously you had to wait for all the   companies that make the web browsers your readers use to update their browsers before   you could use a new content type.  Then you had to hope that all your readers actually did  update their browsers.  Java compatibility is a feature that any browser can implement  and by so doing implement every feature!</p>
<p>For instance let&#8217;s say you   want to use EPS files on your Web site.  Previously you had to wait   until at least one web browser implemented EPS support.    Now you don&#8217;t wait.  Instead you can write your own code to view EPS files and send it to any client that requests your page at the same time  they request the EPS file.</p>
<p>Or suppose you want people to be able to search your electronic card catalog.  However  the card catalog database exists on a mainframe system that doesn&#8217;t speak HTTP.  Before  Java you could hope that some browser implemented your proprietary card catalog protocol;  (fat chance) or you could try to program some intermediate cgi-bin on a UNIX box that  can speak HTTP and talk to the card catalog, not an easy task.  With Java when a client  wants to talk to your card catalog you can send them the code they need to do so.  You don&#8217;t  have to try to force things through an httpd server on port 80 that were never meant to  go through it.</p>
<p>If that were all Java was, it would still be more interesting than a <code>&lt;marquee&gt;</code> or <code>&lt;frame&gt;</code> tag in some new browser beta.  But there&#8217;s a lot more. Java is platform independent.  A Java program can run equally well on any architecture that has a Java enabled browser.  With the release of Netscape Navigator 2.0 that includes Windows 95, Windows NT, the MacOS, Sun Solaris, Sun OS 4.1.3, SGI IRIX, OSF/1, HP-UX with more to come. But wait.  There&#8217;s more!</p>
<p>Java isn&#8217;t just for web sites.  Java is a programming language that lets you do  almost anything you can do with a traditional programming langauge like Fortran or C++. However Java has learned from the mistakes of its predecessors. It is considerably cleaner and easier to use than  those languages.</p>
<p>As a language Java is</p>
<dl>
<dt>Simple </dt>
<dd> Java has the bare bones functionality needed to implement its rich feature set. It does not add lots of syntactic sugar or unnecessary features.</p>
</dd>
<dt>Object-Oriented </dt>
<dd> Almost everything in Java is either a class, a method or an object. Only the most basic primitive operations and data types (int, for, while, etc.) are at a sub-object level.</p>
</dd>
<dt>Platform Independent </dt>
<dd> Java programs are compiled to a byte code format that can be read and run by interpreters on many platforms including Windows 95, Windows NT, and Solaris 2.3 and later.</p>
</dd>
<dt>Safe </dt>
<dd> Java code can be executed in an environment that prohibits it from introducing viruses, deleting or modifying files, or otherwise performing data destroying and computer crashing operations.</p>
</dd>
<dt>High Performance </dt>
<dd> Java can be compiled on the fly with a Just-In-Time compiler (JIT)  to code that rivals C++ in speed.</p>
</dd>
<dt>Multi-Threaded </dt>
<dd> Java is inherently multi-threaded.  A single Java program can have many different things processing independently and continuously.</dd>
</dl>
]]></content:encoded>
			<wfw:commentRss>http://buildingblocksjava.com/part-1-why-javas-cool/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing Java</title>
		<link>http://buildingblocksjava.com/installing-java/</link>
		<comments>http://buildingblocksjava.com/installing-java/#comments</comments>
		<pubDate>Wed, 29 Jul 2009 13:45:44 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://buildingblocksjava.com/?p=81</guid>
		<description><![CDATA[As of this writing Java is not a fully developed commercial product. Versions of Java at varying stages of completion are available from Sun for Windows 95 and Windows NT for X86, Solaris 2.3 to 2.5, and MacOS 7.5. At the present time there are no versions of Java available for MIPS, Alpha or PowerPC [...]]]></description>
			<content:encoded><![CDATA[<p>As of this writing Java is not a fully developed commercial product. Versions of Java at varying stages of completion are available from Sun for Windows 95 and Windows NT for X86, Solaris 2.3 to 2.5, and MacOS 7.5. At the present time there are no versions of Java available for MIPS, Alpha or PowerPC based NT, Windows 3.1, or the Amiga.</p>
<p>Borland is also working a Java development environment to be released in the first half of 1996. Various third-party efforts are under way to port Java to other platforms including the Amiga, Windows 3.1, OS/2 and others.</p>
<p>The basic Java environment consists of a web browser that can play Java applets, a Java compiler to turn to Java source code into byte code, and a Java interpreter to run Java programs. These are the three key components of a Java environment. You&#8217;ll also need a text editor like Brief or BBEdit. Other tools like a debugger, a visual development environment, documentation and a class browser are also nice but aren&#8217;t absolutely necessary.</p>
<p>Note that it isn&#8217;t necessary to get all three of these from the same source. For instance Netscape is committed to providing a Java-enabled web browser. However it will only provide a Java compiler with the next version of its server products.</p>
<p>Sun has made the Java Developers Kit available for its supported platforms. It includes an applet viewer that will let you view and test your applets. The JDK also includes the javac compiler, the java interpreter, the javaprof profiler, the javah header file generator (for integrating C into your Java code), the Java debugger and limited documentation. However most of the documentation for the API and the class library is on Sun&#8217;s web site.</p>
<p>You can ftp the programs from the following sites:</p>
<p>    * USA<br />
          o _ftp://ftp.javasoft.com/pub/<br />
          o _ftp://www.blackdown.org/pub/Java/pub/<br />
          o _ftp://ftp.science.wayne.edu/pub/java/<br />
          o _ftp://metalab.unc.edu/pub/languages/<br />
          o _ftp://java.dnx.com/pub/<br />
    * Germany: _ftp://sunsite.informatik.rwth-aachen.de/pub/mirror/java.sun.com/JDK-beta-win32-x86.exe<br />
    * Korea: _ftp://ftp.kaist.ac.kr/pub/java/e<br />
    * China: _ftp://math01.math.ac.cn/pub/sunsite<br />
    * Japan: _ftp://ftp.glocom.ac.jp/mirror/java.sun.com/<br />
    * Sweden: _ftp://ftp.luth.se/pub/infosystems/www/hotjava/pub/<br />
    * Singapore: _ftp://ftp.iss.nus.sg/pub/java/<br />
    * United Kingdom: _ftp://sunsite.doc.ic.ac.uk/packages/java/ </p>
<p>Macintosh Installation Instructions</p>
<p>The file you get will be a self-extracting archive called something like JDK-1_0_2-MacOS.sea.bin. If you use Fetch or Anarchie to download it will be automatically converted into the self-extracting JDK-1_0_2-MacOS.sea. Double-click it to extract it and the double-click the resulting installer JDK-1_0_2-MacOS. It will prompt you for a location to put it on your hard disk. Put it wherever is convenient.</p>
<p>It may be helpful to make aliases of the Applet Viewer, the Java Compiler and the Java Runner and put them on your desktop for ease of dragging and dropping later, especially if you have a large monitor.</p>
]]></content:encoded>
			<wfw:commentRss>http://buildingblocksjava.com/installing-java/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Windows Installation Instructions</title>
		<link>http://buildingblocksjava.com/windows-installation-instructions/</link>
		<comments>http://buildingblocksjava.com/windows-installation-instructions/#comments</comments>
		<pubDate>Wed, 29 Jul 2009 13:44:35 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://buildingblocksjava.com/windows-installation-instructions/</guid>
		<description><![CDATA[The Windows X86 release is a self extracting archive.  You will need about six megabytes of free disk space to install the JDK. Execute the file by double-clicking on it in the File Manager or by selecting Run&#8230; from the Program Manager&#8217;s File menu and typing the path to the file. This will unpack [...]]]></description>
			<content:encoded><![CDATA[<p>The Windows X86 release is a self extracting archive.  You will need about six megabytes of free disk space to install the JDK. Execute the file by double-clicking on it in the File Manager or by selecting Run&#8230; from the Program Manager&#8217;s File menu and typing the path to the file. This will unpack the archive. The full path is unimportant, but for simplicity&#8217;s sake I am going to assume you installed it from the root of your C: drive. If this is the case the  files will live in C:\java.  If you unpacked it somewhere else just replace C:\ by the full path to the java directory in what follows.</p>
<p>You will need to add C:\java\bin directory to your PATH environment variable</p>
<p>In addition to the java files, the archive includes two common DLL&#8217;s:</p>
<ul>
<li>MSVCRT20.DLL</li>
<li>MFC30.DLL</li>
</ul>
<p>These two files will be installed in your java directory.   If you do not already have copies of these two files on your system, (There&#8217;s a very good chance you do, probably in your system directory.) copy them into the C:\java\bin directory. If you do have these two files already, just delete these extra copies.</p>
]]></content:encoded>
			<wfw:commentRss>http://buildingblocksjava.com/windows-installation-instructions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Unix Installation Instructions</title>
		<link>http://buildingblocksjava.com/unix-installation-instructions/</link>
		<comments>http://buildingblocksjava.com/unix-installation-instructions/#comments</comments>
		<pubDate>Wed, 29 Jul 2009 13:44:01 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://buildingblocksjava.com/unix-installation-instructions/</guid>
		<description><![CDATA[If you&#8217;re on a shared system at a university or an Internet service provider, there&#8217;s a good chance Java is already installed. Ask your local support staff how to access it. Otherwise follow these instructions.
The Unix release is a compressed tar file. You will need about nine megabytes of disk space to uncompress and untar [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re on a shared system at a university or an Internet service provider, there&#8217;s a good chance Java is already installed. Ask your local support staff how to access it. Otherwise follow these instructions.</p>
<p>The Unix release is a compressed tar file. You will need about nine megabytes of disk space to uncompress and untar the JDK. Double that would be very helpful. You do this with the commands:</p>
<pre><samp>% uncompress JDK-1_0_2-solaris2-sparc.tar.Z
% tar xvf JDK-1_0_2-solaris2-sparc.tar
</samp></pre>
<p>The exact file name may be a little different if you�re retrieving the release for a different platform such as Irix or if the version is different. You can untar it in your home directory, or, if you have root privileges, in some convenient place like /usr/local where all users can have access to the files. However root privileges are not necessary to install or run Java. Untarring the file creates all necessary directories and sub-directories. The exact path is unimportant, but for simplicity&#8217;s sake this book assumes it�s installed it in /usr/local. If a sysop already installed it, this is probably where it lives. (Under Solaris it&#8217;s also possible the sysop put it into /opt.) If this is the case the files live in /usr/local/java. If you unpacked it somewhere else, just replace /usr/local by the full path to the java directory in what follows. If you installed it in your home directory, you can use ~/java and ~/hotjava instead of a full path.</p>
<p>You now need to add /usr/local/java/bin directory to your PATH environment variable. You use one of the following commands depending on your shell.</p>
<pre>csh, tcsh:
<code>	% set path=($PATH /usr/local/java/bin)
</code>sh:
<code>	% PATH=($PATH /usr/local/java/bin); export $PATH
</code></pre>
<p>You should also add these lines to the end of your .profile and .cshrc files so you won&#8217;t have to do this every time you login. Now you&#8217;re ready to run some applets.</p>
]]></content:encoded>
			<wfw:commentRss>http://buildingblocksjava.com/unix-installation-instructions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Running Your First Applet</title>
		<link>http://buildingblocksjava.com/running-your-first-applet/</link>
		<comments>http://buildingblocksjava.com/running-your-first-applet/#comments</comments>
		<pubDate>Wed, 29 Jul 2009 13:43:29 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://buildingblocksjava.com/running-your-first-applet/</guid>
		<description><![CDATA[Unix Instructions
Start the Applet Viewer by doing the following:

 Open a command line prompt, and cd to one of the directories in /usr/local/java/demo, for example
% cd /usr/local/java/demo/TicTacToe


 Run the appletviewer on the html file:
% appletviewer example1.html 

 Play Tic-Tac-Toe!  The algorithm was deliberately broken so it is possible to win.

Macintosh Instructions

 Start the Applet [...]]]></description>
			<content:encoded><![CDATA[<h4>Unix Instructions</h4>
<p>Start the Applet Viewer by doing the following:</p>
<ol type="1">
<li> Open a command line prompt, and cd to one of the directories in /usr/local/java/demo, for example
<pre><code>% cd /usr/local/java/demo/TicTacToe
</code></pre>
</li>
<li> Run the appletviewer on the html file:
<pre><code>% appletviewer example1.html </code></pre>
</li>
<li> Play Tic-Tac-Toe!  The algorithm was deliberately broken so it is possible to win.</li>
</ol>
<h4>Macintosh Instructions</h4>
<ol type="1">
<li> Start the Applet Viewer by double-clicking it.</li>
<li> Select Open&#8230; from the File menu and navigate into the java folder, then the Sample Applets folder, then the TicTacToe folder.</li>
<li> Select the file example1.html and click on the Open button. Alternately you can drag and drop this file onto the Applet Viewer.</li>
<li> Play Tic-Tac-Toe! The algorithm was deliberately broken so it is possible to win.</li>
</ol>
<h4>Windows Instructions</h4>
<p>Start the Applet Viewer by doing the following:</p>
<ol type="1">
<li> Open a DOS window, and cd to one of the directories in C:\JAVA\DEMO, for example
<pre><code>C:&lt; cd C:\JAVA\DEMO\TicTacToe
</code></pre>
</li>
<li> Run the appletviewer on the html file:
<pre><code>C:&lt; appletviewer example1.htm </code></pre>
</li>
<li> Play Tic-Tac-Toe!  The algorithm was deliberately broken so it is possible to win.</li>
</ol>
<h6>Hot Tip: Getting Rid of that Annoying License Dialog Box</h6>
<p>Do you know the annoying dialog box I&#8217;m talking about?  I bet you do.  It&#8217;s the one that comes up every time you launch the applet viewer to make you agree to Sun&#8217;s license.  Do you want to get rid of it?  If so make a directory called <em>.hotjava</em> in your java/bin directory.  You won&#8217;t see it again.</p>
]]></content:encoded>
			<wfw:commentRss>http://buildingblocksjava.com/running-your-first-applet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Applets in Netscape</title>
		<link>http://buildingblocksjava.com/applets-in-netscape/</link>
		<comments>http://buildingblocksjava.com/applets-in-netscape/#comments</comments>
		<pubDate>Wed, 29 Jul 2009 13:42:56 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://buildingblocksjava.com/applets-in-netscape/</guid>
		<description><![CDATA[Netscape 3.0 will run Java applets on most platforms except Windows 3.1. Netscape has a Java Demo Page with links to various applets that will mostly run. However do not be surprised if an applet fails to work properly in Netscape.
]]></description>
			<content:encoded><![CDATA[<p>Netscape 3.0 will run Java applets on most platforms except Windows 3.1. Netscape has a Java Demo Page with links to various applets that will mostly run. However do not be surprised if an applet fails to work properly in Netscape.</p>
]]></content:encoded>
			<wfw:commentRss>http://buildingblocksjava.com/applets-in-netscape/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hello World: The Application</title>
		<link>http://buildingblocksjava.com/hello-world-the-application/</link>
		<comments>http://buildingblocksjava.com/hello-world-the-application/#comments</comments>
		<pubDate>Wed, 29 Jul 2009 13:42:10 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://buildingblocksjava.com/hello-world-the-application/</guid>
		<description><![CDATA[At least since the first edition of Kernighan and  Ritchie&#8217;s The C Programming Language it&#8217;s been customary   to begin programming tutorials and classes with the &#8220;Hello World&#8221; program, a program that prints the string &#8220;Hello World&#8221; to the display.  Being heavily influenced by Kernighan and Ritchie and not ones to defy [...]]]></description>
			<content:encoded><![CDATA[<p>At least since the first edition of Kernighan and  Ritchie&#8217;s <cite>The C Programming Language</cite> it&#8217;s been customary   to begin programming tutorials and classes with the &#8220;Hello World&#8221; program, a program that prints the string &#8220;Hello World&#8221; to the display.  Being heavily influenced by Kernighan and Ritchie and not ones to defy tradition we begin similarly.</p>
<p>The following is the Hello World Application as written in Java. Type it into a text file or copy it out of your web browser, and save it as a file named <em>HelloWorld.java</em>.</p>
<pre><code>class HelloWorld {

  public static void main (String args[]) {

    System.out.println("Hello World!");

  }

}</code></pre>
<p>To compile this program make sure you&#8217;re in the same directory HelloWorld.java is in and type <kbd>javac HelloWorld.java</kbd> at the command prompt.  <em>Hello World</em> is very close to the simplest program imaginable. Although it doesn&#8217;t teach very much from a programming standpoint, it gives you a chance to learn the mechanics of writing and compiling code. If you&#8217;re like me your first effort won&#8217;t compile, especially if you typed it in from scratch rather than copying and pasting.  Here  are a few common mistakes:</p>
<li> Did you put a semicolon after <code>System.out.println("Hello World")</code>?</li>
<li> Did you include the closing bracket?</li>
<li> Did you type everything exactly as it appears here? In particular did you use the same capitalization? Java is case sensitive. <code>class</code> is not the same as <code>Class</code> for example.</li>
<li>Were you in the same directory as HelloWorld.java when you typed javac HelloWorld.java?Once your program has compiled successfully, the compiler places the executable output in a file called HelloWorld.class in the same directory as the source code file. You can then run the program by typing <kbd>java HelloWorld</kbd> at the command prompt. As you probably guessed the program responds by  printing  <samp>Hello World!</samp> on your screen.
<p>Congratulations!  You&#8217;ve just written your first Java program!</li>
]]></content:encoded>
			<wfw:commentRss>http://buildingblocksjava.com/hello-world-the-application/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Examining Hello World</title>
		<link>http://buildingblocksjava.com/examining-hello-world/</link>
		<comments>http://buildingblocksjava.com/examining-hello-world/#comments</comments>
		<pubDate>Wed, 29 Jul 2009 13:41:37 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://buildingblocksjava.com/examining-hello-world/</guid>
		<description><![CDATA[Hello World is very close to the simplest program imaginable. Nonetheless there&#8217;s quite a lot going on in it. Let&#8217;s investigate it, line by line.
For now the initial class statement may be thought of as defining the program name, in this case HelloWorld.  The compiler actually got the name for the class file from [...]]]></description>
			<content:encoded><![CDATA[<p><em>Hello World</em> is very close to the simplest program imaginable. Nonetheless there&#8217;s quite a lot going on in it. Let&#8217;s investigate it, line by line.</p>
<p>For now the initial <code>class</code> statement may be thought of as defining the program name, in this case HelloWorld.  The compiler actually got the name for the class file from the <code>class HelloWorld</code> statement in the source code, not from the name of the source code file. If there is more than one class in a file, then the Java compiler will store each one in a separate .class file. For reasons we&#8217;ll see later it&#8217;s advisable to give the source code file the same name as the main class in the file plus the .java extension.</p>
<p>The initial <code>class</code> statement is actually quite a bit more than that since this &#8220;program&#8221; can be called not just from  the command line but also by other parts of the same or different programs.  We&#8217;ll see more in the section on classes and methods below.</p>
<p>The HelloWorld class contains one <dfn>method</dfn>, the main method.  As in C the main method is where an application begins executing.  The method is declared <dfn>public</dfn> meaning that the method can be called from anywhere.  It is declared <dfn>static</dfn> meaning that all instances of this class share this one method.   (If that last sentence was about as intelligible as Linear B, don&#8217;t worry.   We&#8217;ll come back to it later.) It is declared <dfn>void</dfn> which means, as in C, that this method does not return a value.  Finally we pass any command line arguments to the method in an array of Strings called <code>args</code>.  In this simple program there aren&#8217;t any command line arguments though.</p>
<p>Finally when the main method is called it does exactly one thing: print  &#8220;Hello World&#8221; to the standard output, generally a terminal monitor or console window of some sort.  This is accomplished by the <code>System.out.println</code> method.  To be more precise this is accomplished by calling the <code>println()</code> method of the static <code>out</code> field belonging to the <code>System</code> class; but for now we&#8217;ll just treat this as one method.</p>
<p>One final note: unlike the <code>printf</code> function in C the  <code>System.out.println</code> method <em>does</em> append a newline at the end of its output. There&#8217;s no need to include a <code>\n</code> at the end of each string to break a line.</p>
<h6>Exercises</h6>
<ol>
<li>What happens if you change the name of the source code file, e.g. HelloEarth.java instead of HelloWorld.java?</li>
<li>What happens if you keep the name of the source code file the same (HelloWorld.java) but change the class&#8217;s name, e.g. class HelloEarth?</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://buildingblocksjava.com/examining-hello-world/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Braces and Blocks</title>
		<link>http://buildingblocksjava.com/braces-and-blocks/</link>
		<comments>http://buildingblocksjava.com/braces-and-blocks/#comments</comments>
		<pubDate>Wed, 29 Jul 2009 13:41:09 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://buildingblocksjava.com/braces-and-blocks/</guid>
		<description><![CDATA[Let&#8217;s investigate the Hello World program a little more closely.  In Java a source code file is broken up into parts separated by opening and closing braces, i.e. the { and } characters.  Everything between { and } is a block and exists more or less independently of everything outside of the braces.
Blocks [...]]]></description>
			<content:encoded><![CDATA[<p>Let&#8217;s investigate the Hello World program a little more closely.  In Java a source code file is broken up into parts separated by opening and closing braces, i.e. the { and } characters.  Everything between { and } is a <dfn>block</dfn> and exists more or less independently of everything outside of the braces.</p>
<p>Blocks are important both syntactically and logically.  Without the braces the code wouldn&#8217;t compile.  The compiler would have trouble figuring out where one method or class ended and the next one began.  Similarly it would be very difficult for someone else reading your code to understand what was going on.  For that matter it would be very difficult for you, yourself to understand what was going on.  The braces are used to group related statements together.  In the broadest sense everything between matching braces is executed as one statement (though depending not necessarily everything inside the braces is executed every time).</p>
<p>Blocks can be hierarchical. One block can contain one or more subsidiary blocks. In this case we have one outer block that defines the HelloWorld class. Within the HelloWorld block we have a method block called &#8220;main&#8221;.</p>
<p>In this tutorial we help to identify different blocks with indentation.  Every time we enter a new block we indent our source code by two spaces.  When we leave a block we deindent by two spaces. This is a common convention in many programming languages.  However it is not part of the language.  The code would produce identical output if we didn&#8217;t indent it.  In fact I&#8217;m sure you&#8217;ll find a few examples here where I haven&#8217;t followed convention precisely.  Indentation makes the code easier to read and understand, but it does not change its meaning.</p>
]]></content:encoded>
			<wfw:commentRss>http://buildingblocksjava.com/braces-and-blocks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
