tag:blogger.com,1999:blog-14861434788733342702024-03-14T02:54:36.661-07:00JAVA CERTIFICATIONJava certification tutorials and coding examples.rykerhttp://www.blogger.com/profile/09840113935914533757noreply@blogger.comBlogger37125tag:blogger.com,1999:blog-1486143478873334270.post-14483137653582126202011-09-06T10:58:00.000-07:002011-09-06T10:58:32.885-07:00A PHP Tutorial<div dir="ltr" style="text-align: left;" trbidi="on"><span style="font-family: Verdana,Arial,Helvetica,sans-serif;">PHP is an excellent server-side technology for dynamic webpage generation. Within a span of few years, it has gained immense popularity among developers. This excellent 5-Part tutorial written by <i>Luigi Arlotta</i> explains the basics of PHP programming. His style is so simple that even absolute beginners would have no trouble following this tutorial. <br />
<br />
This tutorial is targeted at those users who may have never programmed using any language before. Also programmers who have experience in other languages can quickly browse through this series and get their PHP code running within minutes...<br />
<br />
</span><br />
<a name='more'></a><br />
<span style="font-family: Verdana,Arial,Helvetica,sans-serif;"><b>Introduction</b><br />
</span><br />
<span style="font-family: Verdana,Arial,Helvetica,sans-serif;">PHP stands for "PHP: Hypertext Preprocessor". PHP is a scripting language through which you can generate web pages dynamically. PHP code is directly inserted in HTML documents through specific TAGs declaring the code presence and then executed when a client demands the page. PHP is a server-side language, that's to say that PHP code is directly executed by the server, while the client receives processed results as an HTML document. This way of working is different from that of other scripting languages as JavaScript, whose code is first loaded onto the client machine and then executed by the client (the browser). <br />
<br />
A few points to note about PHP programming -</span><br />
<table align="center" border="0" cellpadding="2" cellspacing="2"><tbody>
<tr> <td align="center" valign="top" width="6%"><span style="font-family: Verdana,Arial,Helvetica,sans-serif;">1.</span></td> <td width="94%"> <span style="font-family: Verdana,Arial,Helvetica,sans-serif;">All compatibility problems existing between different browsers are completely solved. The Client's browser, receives a normal HTML page after the execution of a PHP code on the server, and so it is always able to display it correctly since it deals with only HTML. This does not happen with scripting languages interpreted by the client's browser. In this case the client downloads the script code and tries to process it on the local machine. This procedure works correctly only if the client is equipped with the right software (generally called plugins or built-in support in the browser).</span><br />
</td> </tr>
<tr> <td align="center" valign="top" width="6%"><span style="font-family: Verdana,Arial,Helvetica,sans-serif;">2.</span></td> <td width="94%"> <span style="font-family: Verdana,Arial,Helvetica,sans-serif;">The server side code processing sees to it that the script code is never visible to the clients. That prevents "thefts" of source code.</span><br />
</td> </tr>
<tr> <td align="center" valign="top" width="6%"><span style="font-family: Verdana,Arial,Helvetica,sans-serif;">3.</span></td> <td width="94%"> <span style="font-family: Verdana,Arial,Helvetica,sans-serif;">The server side code execution requires that your webserver has been well configured. It must be able to recognize HTML documents containing PHP code. In order to make this, it is necessary to install a PHP engine and to edit some lines in the webserver's configuration file.</span><br />
</td> </tr>
<tr> <td align="center" height="13" valign="top" width="6%"><span style="font-family: Verdana,Arial,Helvetica,sans-serif;">4.</span></td> <td height="13" width="94%"> <span style="font-family: Verdana,Arial,Helvetica,sans-serif;">Server side code processing needs resources (CPU time) for generating the dynamic pages. A high number of client requests could overload the server. But generally today's servers such as Apache are made stable enough to handle a relatively large number of clients. </span><br />
</td> </tr>
</tbody></table><span style="font-family: Verdana,Arial,Helvetica,sans-serif;">To make the webserver differentiate between HTML documents containing PHP code and normal HTML pages, <i>.php</i>, <i>.php4</i> or <i>.phtml</i> extensions are used in place of the <i>.html</i> . These extensions can change according to the webserver configuration. We shall stick to the standard <i>.php</i> extension.</span><br />
<span style="font-family: Verdana,Arial,Helvetica,sans-serif;">Assume</span><span style="font-family: Verdana,Arial,Helvetica,sans-serif;"> that a client requests the following page (example1.php). The source code for the file is shown below</span><br />
<table align="center" border="0" cellpadding="2" cellspacing="2"><tbody>
<tr bgcolor="#F0F0F0"> <td><span style="font-family: Verdana,Arial,Helvetica,sans-serif;"><HTML> <br />
<BODY> <br />
<? <br />
echo ("<H1>This is an example</H1>"); <br />
?> <br />
</BODY> <br />
</HTML></span></td> </tr>
</tbody></table><span style="font-family: Verdana,Arial,Helvetica,sans-serif;"><br />
This page will be recognized, thanks to the extension from which it is characterized and it will be processed as a HTML document containing PHP code by the server. The code is interpreted before the output is sent to the client. The webserver passes this page through the PHP engine which processes it and executes the PHP instructions in the code. It then substitutes the result of the execution in place of the original PHP code. Once processed by the PHP engine, the webserver then transmits this dynamically generated page to the client. The client receives the following HTML document</span><br />
<table align="center" border="0" cellpadding="2" cellspacing="2"><tbody>
<tr bgcolor="#F0F0F0"> <td><span style="font-family: Verdana,Arial,Helvetica,sans-serif;"> <HTML> <br />
<BODY> <br />
<H1>This is an example</H1> <br />
</BODY> <br />
</HTML> </span></td> </tr>
</tbody></table><span style="font-family: Verdana,Arial,Helvetica,sans-serif;"><br />
<br />
As you see, in the document sent by the web server to the client there is no sign of PHP code. The code has been interpreted/processed and replaced with HTML lines. The client will never be able to deduce what code generated the particular HTML lines.</span><br />
<table align="center" border="0" cellpadding="2" cellspacing="2"><tbody>
<tr bgcolor="#F0F0F0"> <td> <div align="center"><span style="font-family: Verdana,Arial,Helvetica,sans-serif;">PHP instructions are placed inside special TAGs <b><?</b> and<b> ?></b></span></div></td> </tr>
</tbody></table><span style="font-family: Verdana,Arial,Helvetica,sans-serif;"><br />
These tags allow the PHP engine to distinguish the PHP syntax from the rest of the document. It is possible to use different TAGs editing the engine configuration file <i>php.ini .</i> We shall stick to the most common ones - the ones shown above.</span><br />
<span style="font-family: Verdana,Arial,Helvetica,sans-serif;"><b>Necessary Setup to Run PHP on your machine</b></span><br />
<span style="font-family: Verdana,Arial,Helvetica,sans-serif;">To start writing and testing your PHP scripts you need a webserver and a PHP engine. The PHP engine must be combined with the webserver so that the webserver can process the PHP code in your pages. As far as webservers are concerned, on the Linux platform - Apache rules. It is probably the most used webserver at the moment. You can download Apache from <a href="http://www.apache.org/">www.apache.org</a>. The PHP engine (release 3 or 4) can here be downloaded from <a href="http://www.php.net/">www.php.net</a><br />
<br />
</span><span style="font-family: Verdana,Arial,Helvetica,sans-serif;">You could learn how to configure Apache to run PHP with the help of the manual that you would be provided or you could search for articles on Tips For Linux itself.</span><br />
<span style="font-family: Verdana,Arial,Helvetica,sans-serif;"><b> First steps<br />
<br />
</b></span><span style="font-family: Verdana,Arial,Helvetica,sans-serif;">My first PHP script consists of the classic program that displays the famous " HELLO WORLD ". Copy the code shown below, paste and save it in a file with the name <b>helloworld.php</b> in your webserver standard directory (or in the webserver's php files directory).</span><br />
<table align="center" bgcolor="#F0F0F0" border="0" cellpadding="2" cellspacing="2"><tbody>
<tr> <td> <span style="font-family: Verdana,Arial,Helvetica,sans-serif;"><HTML> <br />
<BODY> <br />
<? <br />
echo ("<H1>Hello World!</H1>"); <br />
?> <br />
</BODY> <br />
</HTML> </span><br />
</td> </tr>
</tbody></table><span style="font-family: Verdana,Arial,Helvetica,sans-serif;">Then start your web browser and type the following in the address bar - <br />
<br />
http://127.0.0.1/helloworld.php<br />
<br />
<b>or</b><br />
<br />
http://127.0.0.1/~username/helloworld.php</span><br />
<span style="font-family: Verdana,Arial,Helvetica,sans-serif;"><br />
<b>Note :</b> In case you have not yet configured Apache Server you could read <a href="http://www.codecoffee.com/tipsforlinux/articles/029-1.html">Article No. 29</a> which explains Apache Server's configuration. Once you Apache Server is configured, you could continue with this article.<br />
<br />
If it works correctly you can proceed and read the rest of this tutorial, otherwise you would have to do some more tweaking and get PHP configured on your machine. If you can't solve the problem, before abandoning, try to have a look to the software documentation. Even try posting your problem on discussion forums on the Web. You will definitely find a solution.</span><span style="font-family: Verdana,Arial,Helvetica,sans-serif;"><br />
</span><br />
<span style="font-family: Verdana,Arial,Helvetica,sans-serif;"><b><br />
<br />
Variables<br />
<br />
</b>A variable is a block of memory, accessible through a name chosen by the software developer, in which a value is stored. This value, is usually given a default value at the beginning of the application, and you can change that value during the execution of the program. <i>PHP requires variable names to begin with the dollar ' $ ' character</i>. <br />
<br />
Variable names can be composed of uppercase and lowercase letters, digits and underscores. But it is not possible to include spaces or other special or reserved characters to define the names of a variable. Remember that <i>PHP is a case-sensitive language</i>. This means it distinguishes between uppercase and lowercase variable names. For instance, if we write the following script. The code below shows the case sensitive aspect of PHP.</span><br />
<table align="center" bgcolor="#F0F0F0" border="0" cellpadding="2" cellspacing="2"><tbody>
<tr> <td><span style="font-family: Verdana,Arial,Helvetica,sans-serif;"><HTML> <br />
<HEAD><br />
</HEAD> <br />
<BODY> <br />
<? <br />
$VAR1 = 5; <br />
echo ($var1); <br />
?> <br />
</BODY> <br />
</HTML></span></td> </tr>
</tbody></table><span style="font-family: Verdana,Arial,Helvetica,sans-serif;"><br />
We'll get an error message because the PHP interpreter does not find $var1 variable (The variable defined initially was $VAR1).</span><br />
<span style="font-family: Verdana,Arial,Helvetica,sans-serif;">A script involving variable declarations and displaying the values of those variables is shown below. Read it carefully because it contains some important points that we will discuss later. </span><br />
<table align="center" bgcolor="#F0F0F0" border="0" cellpadding="2" cellspacing="2"><tbody>
<tr> <td><span style="font-family: Verdana,Arial,Helvetica,sans-serif;"><HTML> <br />
<BODY><br />
<? <br />
$website = "http://www.bitafterbit.com"; <br />
echo ("<BR>Surf to: $website"); <br />
echo ('<BR>Surf to: $website'); <br />
?> <br />
</BODY> <br />
</HTML></span></td> </tr>
</tbody></table><span style="font-family: Verdana,Arial,Helvetica,sans-serif;"><br />
The program defines and prints the variable $website. Observe that in the <i>echo()</i> function, whose purpose is to write a string on the screen, two different kinds of inverted commas are used - they are the single and double ones. <br />
<br />
<b>Important</b></span><span style="font-family: Verdana,Arial,Helvetica,sans-serif;"><b> :</b> <i>In this tutorial we will refer to the double inverted commas (") as only inverted commas and we will refer to single inverted commas (') as only quotes. The main difference between these two types of syntax is that PHP interprets what is enclosed in the inverted commas, while everything appearing between quotes is considered a constant value and it is not interpreted. </i><br />
<br />
The example given above produces the following output<br />
<br />
</span><br />
<table align="center" bgcolor="#F0F0F0" border="0" cellpadding="2" cellspacing="2"><tbody>
<tr> <td><span style="font-family: Verdana,Arial,Helvetica,sans-serif;">Surf to: http://www.bitafterbit.com <br />
Surf to: $website </span></td> </tr>
</tbody></table><span style="font-family: Verdana,Arial,Helvetica,sans-serif;"><br />
The text <i>$website</i> is in fact interpreted and replaced with the value of the corresponding variable only in the first echo() statement. This because in the first statement we have used inverted commas to enclose the text to print. The result of this first instruction is<br />
<br />
</span><br />
<table align="center" bgcolor="#F0F0F0" border="0" cellpadding="2" cellspacing="2"><tbody>
<tr> <td><span style="font-family: Verdana,Arial,Helvetica,sans-serif;">Surf to: http://www.bitafterbit.com </span></td> </tr>
</tbody></table><span style="font-family: Verdana,Arial,Helvetica,sans-serif;">As explained previously, in the second <i>echo()</i> statement, where quotes have been used in place of inverted commas, the enclosed text is not interpreted, because it is considered to be a constant. The output of the second <i>echo()</i> instruction therefore is<br />
<br />
</span><br />
<table align="center" bgcolor="#F0F0F0" border="0" cellpadding="2" cellspacing="2"><tbody>
<tr> <td><span style="font-family: Verdana,Arial,Helvetica,sans-serif;">Surf to: $website </span></td> </tr>
</tbody></table><span style="font-family: Verdana,Arial,Helvetica,sans-serif;">It is important to take notice of this important characteristic of PHP. It is different from other programming languages where all that appears enclosed between inverted commas is considered a constant value (a string). We will talk about strings in detail in later articles when we'll discuss PHP's datatypes.</span><span style="font-family: Verdana,Arial,Helvetica,sans-serif;"><br />
</span></div>rykerhttp://www.blogger.com/profile/09840113935914533757noreply@blogger.com0tag:blogger.com,1999:blog-1486143478873334270.post-14155210746706219782011-09-06T03:03:00.001-07:002011-09-06T03:03:01.809-07:00CERIFIACTION TUTORIALS<div dir="ltr" style="text-align: left;" trbidi="on"><h3 class="post-title entry-title"><br />
</h3><div class="post-header"> </div><a href="http://certifiedjava.blogspot.com/2011/08/language-fundamentals.html">TUTORIAL 1 - LANGUAGE FUNDAMENTALS</a><br />
<br />
<a href="http://certifiedjava.blogspot.com/2011/08/operators-and-assignments.html">TUTORIAL 2 - Operators and Assignments - </a><br />
<br />
<a href="http://certifiedjava.blogspot.com/2011/08/declaration-and-access-control.html">TUTORIAL 3 - Declaration and Access Control</a><br />
<br />
<a href="http://certifiedjava.blogspot.com/2011/08/file-handling.html">TUTORIAL 4 - File Handling </a><br />
<br />
<a href="http://certifiedjava.blogspot.com/2011/08/threads.html">TUTORIAL 5 - Threads </a><br />
<br />
<a href="http://certifiedjava.blogspot.com/2011/08/collections.html">TUTORIAL 6 - Collections </a></div>rykerhttp://www.blogger.com/profile/09840113935914533757noreply@blogger.com0tag:blogger.com,1999:blog-1486143478873334270.post-60645263131057087332011-08-30T02:12:00.001-07:002011-08-30T02:12:52.669-07:00TARGETTING<div dir="ltr" style="text-align: left;" trbidi="on">In Robocode, you deplete your opponent's energy and increase your own energy by hitting other bots with bullets. Thus, coming up with targeting algorithms to hit your opponents accurately is a cornerstone of a successful Robocode bot. Different algorithms are more appropriate for different Code Size divisions and styles of play. <br />
The main components of a targeting system are: <br />
<ul><li> Choosing a target (Melee only) </li>
<li> Energy Management - Whether or not to fire, what bullet power to use </li>
<li> Choosing a firing angle </li>
</ul>Most descriptions of Robocode targeting systems focus on choosing a firing angle. For a learning gun, this is essentially a classification problem. The enemy robot can't react to where you fired your bullets because he can't see your gun or your bullets (until they hit). He can, however, see when you fire by monitoring your energy. <br />
Some aspects that make Robocode targeting an interesting classification problem are: <br />
<ul><li> You have a very small amount of time per tick to make a decision. Dropping in the most sophisticated classification algorithm you can find in a textbook won't work. This time needs to be split between inputting data and generating output values. </li>
<li> You have to continually make decisions - when you have no data, when you have 50 ticks, 500 ticks, or 20,000 ticks of data. Your algorithm has to perform well and remain fast enough throughout the entire battle. </li>
</ul></div>rykerhttp://www.blogger.com/profile/09840113935914533757noreply@blogger.com0tag:blogger.com,1999:blog-1486143478873334270.post-50689110193774544292011-08-30T02:11:00.001-07:002011-08-30T02:12:03.582-07:00MOVEMENTS<div dir="ltr" style="text-align: left;" trbidi="on">In Robocode, you deplete your opponent's energy and increase your own energy by hitting other bots with bullets. Thus, coming up with movement algorithms to keep enemies from hitting you is a cornerstone of a successful Robocode bot. Different algorithms are more appropriate for different CodeSize divisions and styles of play. <br />
Melee and 1v1 are the most explored Robocode rule sets, so most movement algorithms could be categorized as most appropriate for one of them. Other rule sets, like Teams, Twin Duel, Droids, and Virtual Combat add various other elements and borrow from Melee and 1v1 movement styles. <br />
In Melee, besides moving unpredictably, it's also very important to choose a stategically beneficial location. For instance, not being closest to any other bot means that you will likely not be targeted by other bots - this allows you to easily collect survival points and also rack up bullet damage against bots that may not be perpendicular to you, making them easier targets. Corners tend to be coveted positions in a Melee battle. You cannot scan the entire battle field every tick in Melee, and Robocode's bullet hit events only fire for bullets that you fire or that hit you, so you have access to a far lower percentage of the total information in the battle. This makes it difficult or impossible to employ precise forms of bullet dodging in Melee. <br />
In 1v1, a primary differentiator of movements at the highest level is bullet dodging. There are still strategic choices, like distancing, attack angle control, dive protection, and staying out of corners (which can limit your Maximum Escape Angle). But distancing is reciprocal, most decent attack angle control schemes perform similarly, and the benefit of staying far away may offset the negative impact of being cornered. Between gathering scans of the enemy every tick and receiving bullet hit events for every bullet that hits you or the enemy, you have a very high amount of information about the battle. About the only thing you are unaware of is the location of enemy bullets that don't (or haven't yet) hit you. Wave Surfing movements with Precise Prediction put all of this together to dodge bullets with surprising accuracy, especially against simple targeters. <br />
For 1v1 in lower weight classes, like MicroBots and NanoBots, there is not enough room to track all of the data needed for Wave Surfing. Still, Stop And Go movements do a great job of dodging simple targeters like Head-On Targeting, and well tuned Random Movement can make your movement fairly unpredictable even to powerful guns by creating a flat movement profile. </div>rykerhttp://www.blogger.com/profile/09840113935914533757noreply@blogger.com0tag:blogger.com,1999:blog-1486143478873334270.post-43849786699299280452011-08-30T02:10:00.000-07:002011-08-30T02:10:12.116-07:00radar<div dir="ltr" style="text-align: left;" trbidi="on">A radar in Robocode can turn a maximum of 45° or π/4<sup>rad</sup> in a single tick. The radar scans robots up to 1200 units away. The angle that the radar rotates between two ticks creates what is called a radar arc, and every robot detected within the arc is sent to the <code>onScannedRobot()</code> method in order of distance from the scanning bot. The closest bot is detected first, while the furthest bot is detected last. By default, the <code>onScannedRobot()</code> method has the lowest event priority of all the event handlers in Robocode, so it is the last one to be triggered each tick.<br />
<br />
<div class="thumb tright"><div class="thumbinner" style="width: 302px;"><a class="image" href="http://robowiki.net/wiki/File:Radar.jpg"><img alt="" class="thumbimage" height="328" src="http://robowiki.net/w/images/a/ac/Radar.jpg" width="300" /></a><br />
For most of these radar locks, you will need to add one of the following to your <code>run()</code> method: <br />
<div class="mw-geshi" dir="ltr" style="text-align: left;"><div class="java5 source-java5"><pre class="de1"> </pre><pre class="de1">setAdjustRadarForRobotTurn<span class="br0">(</span><span class="kw4">true</span><span class="br0">)</span><span class="sy0">;</span>
setAdjustGunForRobotTurn<span class="br0">(</span><span class="kw4">true</span><span class="br0">)</span><span class="sy0">;</span>
setAdjustRadarForGunTurn<span class="br0">(</span><span class="kw4">true</span><span class="br0">)</span><span class="sy0">;</span></pre></div></div><div class="thumbcaption"><div class="magnify"></div> </div><div class="thumbcaption"> </div><div class="thumbcaption"> </div><div class="thumbcaption"> </div></div></div></div>rykerhttp://www.blogger.com/profile/09840113935914533757noreply@blogger.com0tag:blogger.com,1999:blog-1486143478873334270.post-30717697771480072702011-08-30T02:07:00.000-07:002011-08-30T02:07:06.399-07:00GETTING STARTED<div dir="ltr" style="text-align: left;" trbidi="on">After installation first, let's run a battle to see what the game looks like. Simply click the <b>Battle</b> menu, then select <b>New</b>, as shown on the picture here: <br />
<a class="image" href="http://robowiki.net/wiki/File:NewBattle.png" title="Starting a new battle by selecting New in the Battle menu"><img alt="Starting a new battle by selecting New in the Battle menu" height="191" src="http://robowiki.net/w/images/3/32/NewBattle.png" width="241" /></a> <br />
<br />
You'll be presented with the <b>New Battle</b> screen, where you pick the robots and options for a battle. For this battle, we'll try out MyFirstRobot, RamFire, and Tracker. Add them in by double-clicking on their names (or selecting each one and clicking <b>Add</b>) The screen should now look something like this: <br />
<a class="image" href="http://robowiki.net/wiki/File:NewBattleDialog.png" title="Shows the New Battle dialog where the user can select which robots to add to a new battle"><img alt="Shows the New Battle dialog where the user can select which robots to add to a new battle" height="441" src="http://robowiki.net/w/images/4/47/NewBattleDialog.png" width="583" /></a> <br />
See the <b>Number of Rounds</b> box in the middle? <br />
In Robocode, each battle consists of a number of rounds, as you'll see soon. For now, we'll leave it at the default of 10. <br />
Finally, click on the <b>Start Battle</b> button to begin! Watch for Tracker's little dance as he wins rounds. <br />
<h2> <span class="mw-headline" id="See_also"><br />
</span></h2></div>rykerhttp://www.blogger.com/profile/09840113935914533757noreply@blogger.com0tag:blogger.com,1999:blog-1486143478873334270.post-72714826405998628522011-08-30T02:06:00.000-07:002011-08-30T02:06:03.673-07:00COMMAND LINE<div dir="ltr" style="text-align: left;" trbidi="on"> It is possible to specify options and predefined properties from the command-line when running Robocode. The usage of these can be listed by writing this from a command prompt or shell:<br />
<pre><code>robocode -help
</code></pre>For example, it is possible to:<br />
<ul><li>disable the graphical user interface (GUI).</li>
<li>disable security that is specific to Robocode (but does not override the security that comes with the JVM).</li>
<li>enable/disable the debugging mode, useful when debugging robots.</li>
<li>play a battle based on an existing Robocode .battle file.</li>
<li>replay a recorded battle visually.</li>
<li>save the results of battles in a comma-separated file.</li>
</ul>You can read more details here:</div>rykerhttp://www.blogger.com/profile/09840113935914533757noreply@blogger.com0tag:blogger.com,1999:blog-1486143478873334270.post-70663399404443913552011-08-30T02:05:00.002-07:002011-08-30T02:05:38.502-07:00COMPETITION<div dir="ltr" style="text-align: left;" trbidi="on">If you want to challenge your robot(s) and yourself as robot developer, the RoboRumble@Home is the best way to do it. RoboRumble is the ultimate collaborative effort to have a live, up-to-date ranking of Robocode bots. It uses the power of available Robocoders' computers to distribute the effort of running battles and building the rankings.<br />
RoboRumble is actually 3 different rumbles:<br />
<ul><li><b>RoboRumble</b> (aka 1v1): One robot versus another robot - both picked at random. These two robots a alone on the battle field.</li>
<li><b>MeleeRumble</b>: Ten robots picked at random all battle against each other..</li>
<li><b>TeamRumble</b>: One team versus another team - both picked at random. Each team consists of five or less robots.</li>
</ul>In order to get started with RoboRumble, you should read this page:<br />
<ul><li>Starting With RoboRumble</li>
</ul>Note that the RoboRumble@Home client is built into Robocode and can be started using the batch/shell/command files:<br />
<table><thead>
<tr class="header"><th align="left"><br />
</th><th align="left">Windows</th><th align="left">UNIX / Linux</th><th align="left">Mac OS</th></tr>
</thead><tbody>
<tr class="odd"><td align="left"><b>RoboRumble</b></td><td align="left"><code>roborumble.bat</code></td><td align="left"><code>roborumble.sh</code></td><td align="left"><code>roborumble.command</code></td></tr>
<tr class="even"><td align="left"><b>MeleeRumble</b></td><td align="left"><code>meleerumble.bat</code></td><td align="left"><code>meleerumble.sh</code></td><td align="left"><code>meleerumble.command</code></td></tr>
<tr class="odd"><td align="left"><b>TeamRumble</b></td><td align="left"><code>teamrumble.bat</code></td><td align="left"><code>teamrumble.sh</code></td><td align="left"><code>teamrumble.command</code></td></tr>
</tbody></table>Two other competitions exists which are:<br />
<ul><li>Twin Duel: Two teams battle on an 800x800 field. Each team consists of two robots (twins).</li>
<li>Hat League: Two teams not knowing each other are paired together at random (like drawing names from a hat). Each team consists of two robots. These two teams must work together and defeat two other teams that have also been picked at random.</li>
</ul></div>rykerhttp://www.blogger.com/profile/09840113935914533757noreply@blogger.com0tag:blogger.com,1999:blog-1486143478873334270.post-19700048827854528002011-08-30T02:05:00.000-07:002011-08-30T02:05:01.325-07:00CHALLENGES<div dir="ltr" style="text-align: left;" trbidi="on">A good way to improve you self as a robot developer is to try out some real challenges. On the RoboWiki, two famous challenges exist for testing/studying a robots movement, targeting, and gun abilities:<br />
<ul><li>Movement Challenge</li>
<li>Targeting Challenge</li>
<li>RoboRumble Gun Challenge</li>
</ul></div>rykerhttp://www.blogger.com/profile/09840113935914533757noreply@blogger.com0tag:blogger.com,1999:blog-1486143478873334270.post-43462601702629826432011-08-30T02:04:00.001-07:002011-08-30T02:04:22.544-07:00COMMUNITY<div dir="ltr" style="text-align: left;" trbidi="on"><h3></h3>The community around Robocode is using the RoboWiki as communication channel. At the RoboWiki, people share new ideas, code snippets, algorithms, strategies, and lots of other stuff about Robocode. New official documentation from the developers of Robocode will be put at the RoboWiki as well.<br />
On the RoboWiki, these strategies are provided:<br />
<ul><li>Radar</li>
<li>Movement</li>
<li>Targeting</li>
</ul>The code snippets are also provided on the RoboWiki:<br />
<ul><li>Code Snippets</li>
</ul></div>rykerhttp://www.blogger.com/profile/09840113935914533757noreply@blogger.com0tag:blogger.com,1999:blog-1486143478873334270.post-46695764587907209232011-08-30T02:03:00.004-07:002011-08-30T02:03:51.558-07:00ROBOCODE REPOSITORY<div dir="ltr" style="text-align: left;" trbidi="on"><h3></h3>If you want to try out new robots than the sample robots that come with Robocode, you should visit the Robocode Repository.<br />
Robots are available under the Bots section of the repository.<br />
The Robocode Repository is developed and maintained by David Lynn as a project independently of the Robocode project.</div>rykerhttp://www.blogger.com/profile/09840113935914533757noreply@blogger.com0tag:blogger.com,1999:blog-1486143478873334270.post-35711676450105988512011-08-30T02:03:00.002-07:002011-08-30T02:03:29.743-07:00ROBOCODE API<div dir="ltr" style="text-align: left;" trbidi="on"><h3></h3>The Robocode API is provided as HTML pages for both the Java and .NET platform.<br />
<ul><li>Java API</li>
<li>.NET API</li>
<li>.NET Control API</li>
</ul>The Robocode API actually consists of 3 different APIs.<br />
<ul><li><strong>Robot API</strong>: Within the Java package <code>robocode</code> and .NET namespace <code>Robocode</code>.<br />
The Robot API is used for developing robots, and is the only part of the API that robots are allowed to access.</li>
<li><strong>Robot Interfaces</strong>: Within the Java package <code>robocode.robotinterfaces</code> and .NET namespace <code>Robocode.RobotInterfaces</code>.<br />
The Robot Interfaces are used for developing new robot types with a different API that the standard Robot API.<br />
<em><strong>Note:</strong> The game rules and robot behaviors cannot be changed.</em></li>
<li><strong>Control API</strong>: Within the Java package <code>robocode.control</code> and .NET namespace <code>Robocode.Control</code>.<br />
The Control API is used for letting another application start up battles with selected robots in Robocode and retrieve the results. It is also possible to get snapshots of robots and bullets (like position, heading, energy level etc.) at a specific time in a battle.</li>
</ul><div id="robocode-repository"><h3><br />
</h3></div></div>rykerhttp://www.blogger.com/profile/09840113935914533757noreply@blogger.com0tag:blogger.com,1999:blog-1486143478873334270.post-13926141388629791802011-08-30T02:03:00.000-07:002011-08-30T02:18:03.550-07:00GETTING STARTED<div dir="ltr" style="text-align: left;" trbidi="on">Most documentation about Robocode is provided thru the RoboWiki, which contains the official documentation about Robocode, but which also hosts the community around Robocode. It is highly recommended to read the articles on the RoboWiki for getting started with Robocode. These articles are provided from here:<br />
<ul><li><a href="http://certifiedjava.blogspot.com/2011/08/getting-started_30.html">Getting Started</a></li>
</ul>You should read about the anatomy of a robot, the game physics, scoring etc.</div>rykerhttp://www.blogger.com/profile/09840113935914533757noreply@blogger.com0tag:blogger.com,1999:blog-1486143478873334270.post-88161551485236379042011-08-30T02:02:00.001-07:002011-08-30T02:02:17.756-07:00SYSTEM REQUIREMENTS<div dir="ltr" style="text-align: left;" trbidi="on"><br />
<br />
In order to run Robocode, Java 5.0 Standard Edition (SE) or a newer version of Java must be installed on your system. Both the Java Runtime Environment (JRE) and the Java Developer Kit (JDK) can be used. Note that the JRE does not include the standard Java compiler (javac), but the JDK does. However, Robocode comes with a built-in compiler (ECJ). Hence, it is sufficient running Robocode on the JRE.<br />
<br />
Also note that it is important that these environment variables have been set up prior to running Robocode:<br />
<br />
JAVA_HOME must be setup to point at the home directory for Java (JDK or JRE).<br />
Windows example: JAVA_HOME=C:\Program Files\Java\jdk1.5.0_22<br />
UNIX, Linux, Mac OS example: JAVA_HOME=/usr/local/jdk1.5.0_22<br />
<br />
PATH must include the path to the bin of the Java home directory (JAVA_HOME) that includes java.exe for starting the Java virtual Machine (JVM).<br />
Windows example: PATH=%PATH%;%JAVA_HOME%<br />
UNIX, Linux, Mac OS example: PATH=${PATH}:${JAVA_HOME}/bin<br />
<br />
You can read more details from here:<br />
<br />
System Requirements<br />
<br />
If you want to program robots in .NET or control Robocode from a .NET application, you need to install the Robocode .NET API plug-in on top of Robocode. The plug-in is installed by double-clicking the robocode.dotnet-xxx-setup.jar the same way as Robocode itself is installed.</div>rykerhttp://www.blogger.com/profile/09840113935914533757noreply@blogger.com0tag:blogger.com,1999:blog-1486143478873334270.post-84718130228254348952011-08-30T02:01:00.007-07:002011-08-30T02:01:55.275-07:00HISTORY OF ROBOCODE<div dir="ltr" style="text-align: left;" trbidi="on"><h3><br />
</h3>The Robocode game was originally started by Matthew A. Nelson, aka Mat Nelson, as a personal endeavor in late 2000 and became a professional one when he brought it to IBM, in the form of an AlphaWorks download, in July 2001.<br />
In the beginning of 2005, Robocode was brought to SourceForge as Open Source with Robocode version 1.0.7. At this point, the development of Robocode had somewhat stopped. In the meanwhile, the community around Robocode began to develop their own versions of Robocode in order to get rid of bugs and also to put new features into Robocode, the Contributions for Open Source Robocode and later on the RobocodeNG project by Flemming N. Larsen.<br />
As nothing seemed to happen with Robocode in more than a year, Flemming N. Larsen took over the Robocode project at SourceForge as administrator and developer in July 2006. The RobocodeNG project was dropped, but the Robocode 2006 variant, which contained a lot of contributions from the Robocode community, was merged into the official Robocode with version 1.1. Since then, lots of new versions of Robocode have been released with more and more features and contributions from the community.<br />
Recently (from version 1.7.2.0), the .NET platform is supported through a .NET plug-in provided by Pavel Savara based on jni4net, also developed by Pavel Savara.</div>rykerhttp://www.blogger.com/profile/09840113935914533757noreply@blogger.com0tag:blogger.com,1999:blog-1486143478873334270.post-52700873485181503712011-08-30T02:01:00.005-07:002011-08-30T02:01:29.663-07:00WHAT IS ROBOCODE?<div dir="ltr" style="text-align: left;" trbidi="on">Robocode is a programming game, where the goal is to develop a robot battle tank to battle against other tanks in Java or .NET. The robot battles are running in real-time and on-screen.<br />
<br />
The motto of Robocode is: Build the best, destroy the rest!<br />
<br />
Besides being a programming game, Robocode is used for learning how to program, primarily in the Java language, but other languages like C# and Scala are becoming popular as well.<br />
<br />
Schools and universities are using Robocode as part of teaching how to program, but also for studying artificial intelligence (AI). The concept of Robocode is easy to understand, and a fun way to learn how to program.<br />
<br />
Robocode comes with its own installer, built-in robot editor and Java compiler, and only pre-requires a Java Virtual Machine (JVM) to exist on the system where it must be installed. Hence, everything a robot developer needs to get started is provided with the main Robocode distribution file (robocode-xxx-setup.jar). Robocode also supports developing robots using external IDEs like e.g. Eclipse, IntelliJ IDEA, NetBeans, Visual Studio etc., which supports the developer much better than the robot editor in Robocode.<br />
<br />
The fact that Robocode runs on the Java platform makes it possible to run it on any operating system with Java pre-installed, meaning that it will be able to run on Windows, Linux, Mac OS, but also UNIX and variants of UNIX. Note that Java 5.0 or newer must be installed on the system before Robocode is able to run. See the System Requirements for more information.<br />
<br />
Be aware that many users of Robocode (aka Robocoders) find Robocode to be very fun, but also very addictive. :-)<br />
<br />
Robocode comes free of charge and is being developed as a spare-time project where no money is involved. The developers of Robocode are developing on Robocode because they think it is fun, and because they improve themselves as developers this way.<br />
<br />
Robocode is an Open Source project, which means that all sources are open to everybody. In addition, Robocode is provided under the terms of EPL (Eclipse Public License).</div>rykerhttp://www.blogger.com/profile/09840113935914533757noreply@blogger.com0tag:blogger.com,1999:blog-1486143478873334270.post-28926909558758261932011-08-28T02:14:00.001-07:002011-08-28T02:14:27.871-07:00Collections<div dir="ltr" style="text-align: left;" trbidi="on"><br />
<dl><dt>Collections</dt>
<dd>A Collection allows a group of objects to be treated as a single unit. Collections define a set of core interfaces. These are -
<ul><li>Collection</li>
<li>Set </li>
<li>List</li>
<li>SortedSet </li>
<li>Map</li>
<li>SortedMap</li>
</ul>
Collections also provide implementation for these interfaces. </dd>
<a name='more'></a>
<dt>Core Interfaces</dt>
<dd>The Object hierarchy of Core Interfaces defined in Collections is given below. <center> <img src="http://www.javaprepare.com/fig_coll.gif" /> </center> <em><b>Figure:</b> Core Interfaces of Collections</em> </dd>
<dt>Collection Interface</dt>
<dd>The Collection interface is the root of Collection hierarchy, and is used for common functionality across all collections. There is no direct implementation of Collection interface. </dd>
<dt>Set Interface</dt>
<dd>The Set interface is used to represent a group of unique elements. It extends the Collection interface. The class HashSet implements the Set interface. </dd>
<dt>SortedSet Interface</dt>
<dd>The SortedSet interface extends the Set interface. It provides extra functionality of keeping the elements sorted. So SortedSet interface is used to represent collections consisting of unique, sorted elements. The class TreeSet is an implementation of interface SortedSet.</dd>
<dt>List Interface</dt>
<dd>The list interface extends the Collection interface to represent sequence of numbers in a fixed order. Classes ArrayList, Vector and LinkedList are implementation of List interface. </dd>
<dt>Map Interface</dt>
<dd>The Map Interface is a basic interface that is used to represent mapping of keys to values. Classes HashMap and Hashtable are implementations of Map interface. </dd>
<dt>SortedMap Interface</dt>
<dd>The SortedMap Interface extends Map interface and maintains their mappings in key order. The class TreeMap implements SortedMap interface. </dd> The table below gives the list of Collection interfaces and the classes that implement them.
<table bgcolor="#F5F5DC" border="1"><tbody>
<tr> <td><b>Interface</b></td> <td><b>Class Implementation</b> </td> </tr>
<tr> <td>Set</td> <td>HashSet</td> </tr>
<tr> <td>SortedSet</td> <td>TreeSet</td> </tr>
<tr> <td>List</td> <td>ArrayList, Vector, LinkedList</td> </tr>
<tr> <td>Map</td> <td>HashMap, Hashtable</td> </tr>
<tr> <td>SortedMap</td> <td>TreeMap</td></tr>
</tbody></table></dl></div>rykerhttp://www.blogger.com/profile/09840113935914533757noreply@blogger.com0tag:blogger.com,1999:blog-1486143478873334270.post-51419755860368387282011-08-28T02:13:00.000-07:002011-08-28T02:24:15.866-07:00Threads<div dir="ltr" style="text-align: left;" trbidi="on"><br />
<dl><dt>Threads </dt>
<dd> A thread is in process in execution within a program. Within a program each thread defines a separate path of execution. </dd>
<dt> Creation of a thread </dt>
<dd> A thread can be created in two ways a) By implementing the Runnable interface. The Runnable interface consists of only one method - the run method. The run method has a prototype of <code> <span style="color: red;"> public void run(); </span> </code> b) By extending the class Thread. </dd>
<dt> Execution of a thread </dt>
<dd> To execute a thread, the thread is first created and then the start() method is invoked on the thread. Eventually the thread would execute and the run method would be invoked. The example below illustrates the two methods of thread creation. You should note that the run method should not be invoked directly. <code> </code> <pre><code><span style="color: red;">
public class ThreadExample extends Thread {
public void run() {
System.out.println("Thread started");
}
public static void main(String args[]) {
ThreadExample t = new ThreadExample();
t.start();
}
}
Example - Creation of Thread by extending the
Thread class.
</span>
</code></pre><a name='more'></a>
<code> </code> When the run method ends, the thread is supposed to "die". The next example shows the creation of thread by implementing the Runnable interface. <code> </code> <pre><code><span style="color: red;">
public class ThreadExample2 implements Runnable {
public void run() {
.../* Code which gets executed when
thread gets executed. */
}
public static void main(String args[]) {
ThreadExample2 Tt = new ThreadExample2();
Thread t = new Thread(Tt);
t.start();
}
}
Example - Creating thread by implementing Runnable
</span>
</code></pre><code> </code> </dd>
<dt> States of thread </dt>
<dd> A thread can be in one of the following states - ready, waiting for some action, running, and dead. These states are explained below. <b>Running State</b> A thread is said to be in running state when it is being executed. This thread has access to CPU. <b>Ready State </b> A thread in this state is ready for execution, but is not being currently executed. Once a thread in the ready state gets access to the CPU, it gets converted to running state. <b>Dead State </b> A thread reaches "dead" state when the run method has finished execution. This thread cannot be executed now. <b>Waiting State </b> In this state the thread is waiting for some action to happen. Once that action happens, the thread gets into the ready state. A waiting thread can be in one of the following states - sleeping, suspended, blocked, waiting for monitor. These are explained below. </dd>
<dt>Yielding to other processes </dt>
<dd> A CPU intensive operation being executed may not allow other threads to be executed for a "large" period of time. To prevent this it can allow other threads to execute by invoking the yield() method. The thread on which yield() is invoked would move from running state to ready state. </dd>
<dt> Sleep state of a thread </dt>
<dd> A thread being executed can invoke the sleep() method to cease executing, and free up the CPU. This thread would go to the "sleep" state for the specified amount of time, after which it would move to the "ready" state. The sleep method has the following prototypes. <code> </code><pre><span style="color: red;">
public static void sleep (long millisec)
throws InterruptedException;
public static void sleep (long millisec, int nanosec)
throws InterruptedException;
</span>
</pre></dd>
<dt> Synchronized state</dt>
<dd> A code within the synchronized block is "atomic". This means only one thread can execute that block of code for a given object at a time. If a thread has started executing this block of code for an object, no other thread can execute this block of the code (or any other block of synchronized code) for the same object. <code> </code><pre><span style="color: red;">
public synchronized void synchExample() {
/* A set of synchronized statements. Assume
here that x is a data member of this class. */
if(x == 0)
x = 1;
}
</span>
</pre></dd></dl></div>rykerhttp://www.blogger.com/profile/09840113935914533757noreply@blogger.com0tag:blogger.com,1999:blog-1486143478873334270.post-87739495120567225422011-08-28T02:11:00.000-07:002011-08-28T02:11:02.990-07:00Declaration and Access ControlArray Fundamentals<br />
Arrays are used to represent fixed number of elements of the same type. The following are legal syntax for declaring one-dimensional arrays.<br />
<br />
int anArray[];<br />
int[] anArray;<br />
int []anArray;<br />
<br />
It is important to note that the size of the array is not included in the declaration. Memory is allocated for an array using the new operator as shown below.<br />
anArray = new int[10];<br />
The declaration and memory allocation may be combined together as shown below.<br />
int anArray[] = new int[10];<br />
The elements of the array are implicitly initialized to default values based on array types (0 for integral types, null for objects etc.). This is true for both local arrays as well as arrays which are data members. In this respect arrays are different from normal variables. Variable defined inside a method are not implicitly initialized, where as array elements are implicitly initialized.<br />
<br />
Array Initializations<br />
Arrays are initialized using the syntax below<br />
int intArray[] = {1,2,3,4};<br />
The length operator can be used to access the number of elements in an array (for example - intArray.length). <br />
<a name='more'></a><br />
Multidimensional Arrays<br />
The following are legal examples of declaration of a two dimensional array.<br />
int[] arr[];<br />
int[][] arr;<br />
int arr[][];<br />
int []arr[];<br />
<br />
When creating multi-dimensional arrays the initial index must be created before a later index. The following examples are legal.<br />
<br />
int arr[][] = new int[5][5];<br />
int arr[][] = new int[5][];<br />
<br />
The following example will not compile;<br />
int arr[][] = new int[][5];<br />
<br />
Class Fundamentals<br />
A class defines a new type and contains methods and variables. The example below illustrates a simple class.<br />
<br />
<br />
class City {<br />
String name; // member variable <br />
String getName() // member method<br />
{<br />
return name;<br />
}<br />
public static void main(String arg[]) {<br />
}<br />
}<br />
<br />
Method overloading<br />
JavaTM technology allows two methods to have the same name as long as they have different signatures. The signature of a method consists of name of the method, and count and type of arguments of the method. Thus as long as the argument types of two methods are different, they may be over-loaded (have the same name). <br />
<br />
Class constructors<br />
Constructors are member methods that have same name as the class name. The constructor is invoked using the new operator when a class is created. If a class does not have any constructors then Java language compiler provides an implicit default constructor. The implicit default constructor does not have any arguments and is of the type -<br />
class_name() { }<br />
<br />
If a class defines one or more constructors, an implicit constructor is not provided. The example below gives a compilation error.<br />
<br />
<br />
class Test {<br />
int temp;<br />
Test(int x) {<br />
temp = x;<br />
}<br />
public static void main() {<br />
Test t = new Test(); /* This would generate a <br />
compilation error, as there is no constructor <br />
without any arguments. */<br />
}<br />
}<br />
<br />
rykerhttp://www.blogger.com/profile/09840113935914533757noreply@blogger.com0tag:blogger.com,1999:blog-1486143478873334270.post-16363935633111475792011-08-28T02:10:00.000-07:002011-08-28T02:10:10.091-07:00Operators and Assignments<div dir="ltr" style="text-align: left;" trbidi="on">Operators and Assignments<br />
<br />
Commonly used operators<br />
Following are some of the commonly used JavaTM technology operators - Multiplication (*), Addition (+), Subtraction (-), logical and (&&) Conditional Operator ?:, Assignment (=), left shift (<<), right shift (>> and >>>), Equality comparison (==), Non-equality comparison (!=).<br />
<br />
Conversion rules in Assignments<br />
In the description below, I am giving basic conversion rules for assignment when source and destination are of different types.<br />
<a name='more'></a><br />
If source and destination are of the same type, assignment happens without any issues.<br />
If source is of smaller size than destination but source and destination are of compatible types, then no casting is required. Implicit widening takes place in this case. An example is assigning an int to a long.<br />
If source and destination are of compatible types, but source is of larger size than destination, explicit casting is required. In this case, if no casting is provided then the program does not compile. <br />
<br />
Floating point numbers<br />
Decimal numbers (for example 1.3) are of type double by default. To make them of type float they must be followed by F (say, 1.3F).<br />
<br />
The equality operator<br />
The equality operator (==) when applied to objects return true if two objects have same reference value, false otherwise. The example below illustrates this --<br />
<br />
<br />
String str1 = "first string";<br />
String str2 = new String("first string");<br />
String str3 = "first string";<br />
boolean test1 = (str1 == str2);<br />
boolean test2 = (str1 == str3);<br />
<br />
In the example above, test1 is set to false because str1 and str2 point to different references. As str1 and str3 point to the same reference, test2 gets set to true. When a string is initialized without using the new operator, and with an existing string, then the new string also points to the first string's location. So in the example above, str1 and str3 point to the same pool of memory and hence test2 gets set to true. The string str2 on the other hand is created using the new operator and hence points to a different block of memory. Hence test1 gets set to false. <br />
<br />
The conditional operators && and ||<br />
Operator && returns true if both operands are true, false otherwise. Operator || returns false if both operands are false, true otherwise. The important thing to note about these operators is that they are short-circuited. This means that the left operand is evaluated before the right operator. If the result of the operation can be evaluated after computing the left operand, then the right side is not computed. In this respect these operators are different from their bit-wise counterparts - bit-wise and (&), and bit-wise or (|). The bit-wise operators are not short-circuited. This means both the operands of bit-wise operator are always evaluated independent of result of evaluations. <br />
<br />
Storing integral types<br />
All the integer types in Java technology are internally stored in two's complement. In two's complement, positive numbers have their corresponding binary representation. Two's complement representation of negative numbers is generated using the following three step process -<br />
<br />
First get the binary representation of the number.<br />
Then interchange zeros and ones in the binary representation.<br />
Finally add one to the result. So for example two's complement of -18 would be (assuming one byte representation) -<br />
Converting 18 to binary -- 0001 0010<br />
Interchanging 0s and 1s -- 1110 1101<br />
Adding 1 -- 1110 1110 <br />
<br />
So 1110 1110 would be binary representation of -18 using two bytes and using two's complement representation. <br />
<br />
The shift operators<br />
The shift left operator in Java technology is "<<". There are two operators for doing the right shift - signed right shift (>>) and zero fill right shift (>>>).<br />
<br />
The left shift operator fills the right bits by zero. The effect of each left shift is multiplying the number by two. The example below illustrates this -<br />
<br />
int i = 13; // i is 00000000 00000000 00000000 0000 1101<br />
i = i << 2; // i is 00000000 00000000 00000000 0011 0100 After this left shift, i becomes 52 which is same as multiplying i by 4 Zero fill shift right is represented by the symbol >>>. This operator fills the leftmost bits by zeros. So the result of applying the operator >>> is always positive. (In two's complement representation the leftmost bit is the sign bit. If sign bit is zero, the number is positive, negative otherwise.) The example below illustrates applying the operator >>> on a number.<br />
<br />
int b = 13; // 00000000 00000000 00000000 0000 1101<br />
b = b >>> 2; // b is now 00000000 00000000 00000000 0000 0011<br />
<br />
So the result of doing a zero fill right shift by 2 on 13 is 3. The next example explains the effect of applying the operator >>> on a negative number.<br />
<br />
int b = -11; //11111111 11111111 11111111 1111 0101<br />
b = b >>> 2; // b now becomes 00111111 11111111 11111111 1111 1101<br />
<br />
So the result of applying zero fill right shift operator with operand two on -11 is 1073741821.<br />
<br />
Signed right shift operator (>>) fills the left most bit by the sign bit. The result of applying the signed shift bit has the same sign as the left operand. For positive numbers the signed right shift operator and the zero fill right shift operator both give the same results. For negative numbers, their results are different. The example below illustrates the signed right shift.<br />
<br />
int b = -11; // 11111111 11111111 11111111 1111 0101<br />
b = b >> 2; // 11111111 11111111 11111111 1111 1101 (2's complement of -3)<br />
// Here the sign bit 1 gets filled in the two most significant bits.<br />
<br />
The new value of b becomes -3. </div>rykerhttp://www.blogger.com/profile/09840113935914533757noreply@blogger.com0tag:blogger.com,1999:blog-1486143478873334270.post-35570536468429919242011-08-28T02:02:00.001-07:002011-08-28T02:07:32.290-07:00LANGUAGE FUNDAMENTALS<div dir="ltr" style="text-align: left;" trbidi="on"><h3><center>Language Fundamentals</center></h3><br />
<ol type="I"><li>Identifiers are names of variables, functions, classes etc. The name used as an identifier must follow the following rules in Java<sup>TM</sup> technology. <ul><li>Each character is either a digit, letter, underscore(_) or currency symbol ($,¢, £ or ¥) </li>
<li>First character cannot be a digit. </li>
<li>The identifier name must not be a reserved word. </li>
</ul></li>
<li>A keyword or reserved word in Java technology has special meaning and cannot be used as a user defined identifier. The list of keywords in Java technology is given below. It is important to completely remember this list as you can expect a question in Java Certification exam related to this. <br />
<table align="center" bgcolor="#F5F5DC" border="1" cellpadding="0" cellspacing="0"><tbody>
<tr><td>abstract</td><td>boolean</td><td>break</td><td>byte</td><td>case</td><td>catch</td></tr>
<tr><td>char</td><td>class</td><td><i>const</i></td><td>continue</td><td>default</td><td>do</td></tr>
<tr><td>double</td><td>else</td><td>extends</td><td>final</td><td>finally</td><td>float</td></tr>
<tr><td>for</td><td><i>goto</i></td><td>if</td><td>implements</td><td>import</td><td>instanceof</td></tr>
<tr><td>int</td><td>interface</td><td>long</td><td>native</td><td>new</td><td>null</td></tr>
<tr><td>package</td><td>private</td><td>protected</td><td>public</td><td>return</td><td>short</td></tr>
<tr><td>static</td><td>strictfp</td><td>super</td><td>switch</td><td>synchronized</td><td>this</td></tr>
<tr><td>throw</td><td>throws</td><td>transient</td><td>try</td><td>void</td><td>volatile</td></tr>
<tr><td>while</td><td>assert</td><td>enum</td> <td></td><td></td><td></td></tr>
</tbody></table><a name='more'></a><br />
It is important to note the following <br />
<ol type="A"><li>const and goto are not currently in use. </li>
<li>null, true, and false are reserved literals but can be considered as reserved words for the purpose of exam. </li>
<li>It is important to understand that Java language is case-sensitive. So even though super is a keyword, Super is not.</li>
<li>All the Java technology keywords are in lower case.</li>
<li>strictfp is a new keyword added in Java 1.2. assert is added in Java 1.4 and enum in Java 5.0</li>
<li>The list of keywords as defined by Sun is present <a href="http://java.sun.com/docs/books/tutorial/java/nutsandbolts/_keywords.html">here.</a> </li>
</ol></li>
<li>A literal in Java technology denotes a constant value. So for example 0 is an integer literal, and 'c' is a character literal. The reserved literals true and false are used to represent boolean literals. "This is a string" is a string literal. </li>
<li>Integer literals can also be specified as octal (base 8), or hexadecimal (base 16). Octal and hexadecimal have 0 and 0x prefix respectively. So 03 and 0x3 are representation of integer three in octal and hexa-decimal respectively. </li>
<li>Java technology supports three type of comments <ol type="A"><li>A single line comment starting with // </li>
<li>A multi-line comment enclosed between /* and */ </li>
<li>A documentation or javadoc comment is enclosed between /** and */. These comments can be used to generate HTML documents using the javadoc utility, which is part of Java language. </li>
</ol></li>
<li>Java technology supports the following primitive types - boolean (for representing true or false), a character type called char, four integer types (byte, short, int and long) and two floating point types (float and double). The details of these types are given below - <br />
<table bgcolor="#F5F5DC" border="1"><tbody>
<tr> <td><b>Data types</b></td> <td><b>Width (in bytes)</b> </td> <td><b>Minimum value</b></td> <td><b>Maximum Value</b></td> </tr>
<tr> <td>byte</td> <td>1</td> <td>-2<sup>7</sup></td> <td>2<sup>7</sup> - 1</td> </tr>
<tr> <td>short</td> <td>2</td> <td>-2<sup>15</sup></td> <td>2<sup>15</sup>-1</td> </tr>
<tr> <td>int</td> <td>4</td> <td>-2<sup>31</sup></td> <td>2<sup>31</sup> - 1</td> </tr>
<tr> <td>long</td> <td>8</td> <td>-2<sup>63</sup></td> <td>2<sup>63</sup> - 1</td> </tr>
<tr> <td>char</td> <td>2</td> <td>0x0</td> <td>0xffff</td> </tr>
<tr> <td>float</td> <td>4</td> <td>1.401298e<sup>-45</sup></td> <td>3.402823e<sup>+38</sup></td> </tr>
<tr> <td>double</td> <td>8</td> <td>4.940656e<sup>-324</sup></td> <td>1.797693e<sup>+308</sup></td> </tr>
</tbody></table><br />
</li>
<li> Corresponding to all the primitive type there is a wrapper class defined. These classes provide useful methods for manipulating primitive data values and objects. <br />
<table bgcolor="#F5F5DC" border="1"><tbody>
<tr> <td><b>Data types</b></td> <td><b>Wrapper class</b> </td> </tr>
<tr> <td>int</td> <td>Integer</td> </tr>
<tr> <td>short</td> <td>Short</td> </tr>
<tr> <td>long</td> <td>Long</td> </tr>
<tr> <td>byte</td> <td>Byte</td> </tr>
<tr> <td>char</td> <td>Character</td> </tr>
<tr> <td>float</td> <td>Float</td> </tr>
<tr> <td>double</td> <td>Double</td> </tr>
</tbody></table><br />
</li>
<li> Instance variables (data members of a class) and static variables are initialized to default values. Local variables (i.e. variables defined in blocks or inside member functions) are not initialized to default values. Local variables must be explicitly initialized before they are used. If local variables are used before initialization, compilation error gets generated. The defaults for static and instance variables are given in the table below. <br />
<table bgcolor="#F5F5DC" border="1"><tbody>
<tr> <td><b>Data types</b></td> <td><b>Default Values</b> </td> </tr>
<tr> <td>boolean</td> <td>false</td> </tr>
<tr> <td>char</td> <td>'\u0000'</td> </tr>
<tr> <td>Integer types (byte, short, int, long)</td> <td>0</td> </tr>
<tr> <td>Floating types (float, double)</td> <td>0.0F or 0.0 D</td> </tr>
<tr> <td>Object References</td> <td>null</td> </tr>
</tbody></table><br />
<code> </code><br />
<pre><code><span style="color: red;">
public static void main(String args[]) {
int i;
System.out.println(i);
}
</span>
</code></pre><code> </code> In this example printing of i generates a compilation error because local variable i is used before being initialized. The initialization of instance and static variables is an important concept both for understanding of Java language, and for Java Certification exam. </li>
<li> A Java source file has the following elements in this specific order. <ul><li>An optional package statement. All classes and interfaces defined in the file belong to this package. If the package statement is not specified, the classes defined in the file belong to a default package. An example of a package statement is - <br />
<code>package testpackage;</code> </li>
<li>Zero or more import statements. The import statement makes any classes defined in the specified package directly available. For example if a Java source file has a statement importing the class "java.class.Button", then a class in the file may use Button class directly without providing the names of the package which defines the Button class. Some examples of import statement are - <br />
<code> <span style="color: red;"> import java.awt.*; // All classes in the awt package are imported. <br />
import java.applet.Applet; </span> </code> </li>
<li>Any number of class and interface definitions may follow the optional package and import statements. </li>
</ul>If a file has all three of the above constructs, they must come in the specific order of package statement, one or more import statements, followed by any number of class or interface definitions. Also all the above three constructs are optional. So an empty file is a legal Java file. </li>
<li>The Java interpreter executes a method called main, defined in the class specified in command line arguments. The main method is the entry point for execution of a class. In Java technology the main method must have the following signature - <br />
<code> <span style="color: red;"> public static void main(String args[]) </span> </code> <br />
The java interpreter is invoked with the name of the class as an argument. The class name is followed by possible set of arguments for the main function of the class. When a Java program is invoked then the Java interpreter name "java" and the class name are not passed to the main() method of the class. The rest of the command line arguments are passed as an array of String. For example invoking <code> <span style="color: red;">java Sky blue gray </span> </code><br />
would invoke main method of Sky class with an array of two elements - blue and gray. </li>
</ol></div>rykerhttp://www.blogger.com/profile/09840113935914533757noreply@blogger.com0tag:blogger.com,1999:blog-1486143478873334270.post-76082927762065796562011-08-26T12:00:00.003-07:002011-08-26T12:16:14.057-07:00AGLETS<div dir="ltr" style="text-align: left;" trbidi="on"><a href="http://certifiedjava.blogspot.com/p/aglets.html"></a>Think of the Internet as a distributed, massively parallel supercomputer that connects information repositories, databases, intelligent agents, and mobile code. Imagine sending your own personalized agents to roam the Internet. They will monitor your favorite Web sites, get you the ticket you couldn't get at the box office, or help you to schedule meetings for your next overseas trip. Sounds like science fiction? Maybe, but at IBM Research we decided to do something about it. Read on and learn about Aglets Software Development Kit from IBM. We are confident that you will be excited about what you discover!<br />
INSTALL AGLETS AND GET STARTED<br />
<a href="http://certifiedjava.blogspot.com/p/aglets.html">CLICK TO INSTALL</a></div>rykerhttp://www.blogger.com/profile/09840113935914533757noreply@blogger.com0tag:blogger.com,1999:blog-1486143478873334270.post-78166081049299063972011-08-26T08:51:00.000-07:002011-08-26T08:51:01.785-07:00Installing ANT for Windows 71. Download ANT http://ant.apache.org/<br />
2. Unzip it and rename it to ant<br />
<br />
3.Set environmental variables JAVA_HOME to your Java environment, ANT_HOME to the directory you uncompressed, to do it on command prompt type this (Assume Ant is installed in E:\ant\.)<br />
<br />
set ANT_HOME=E:\ant<br />
set JAVA_HOME=D:\Program Files\Java\jdk1.6.0_03<br />
set PATH=%PATH%;%ANT_HOME%\bin<br />
<br />
In windows 7 you can go to Control Panel\All Control Panel Items\System or right click on Computer and then to “Advance system setting”<br />
-Choose Advanced Tab<br />
-Press Environtmen Variables Button<br />
-In the System Variables, click New Button<br />
<br />
Give the Variable Name:ANT_HOME<br />
Give the Value: E:\ant<br />
Click OK<br />
Then,we’ll add new ANT_HOME path,<br />
And Click again on New Button if you do not have ‘path’ Variable in there, if so select it and edit as<br />
Give the Variable Name:path<br />
Give the Value D:\Program Files\Java\jdk1.6.0_03\bin;%ANT_HOME%\bin<br />
Click OK<br />
<br />
4. Check wheter ANT works correctly or not.<br />
In the command prompt, type:<br />
ant -version<br />
<br />
I got Apache Ant version 1.8.1 compiled on April 30 2010<br />
<br />
what on you?rykerhttp://www.blogger.com/profile/09840113935914533757noreply@blogger.com0tag:blogger.com,1999:blog-1486143478873334270.post-37057974515748904922011-08-26T05:09:00.000-07:002011-08-26T05:11:43.474-07:00set JAVA_HOME envoirment<div dir="ltr" style="text-align: left;" trbidi="on">FOR WINDOWS:<br />
Please follow the instructions to set up JAVA_HOME environment variable in your computer. First find out the installation folder of Java development kit (JDK) in your machine. Let's assume it is installed in the folder "C:/j2sdk1.4.2"<br />
<br />
1 Right click on the My Computer icon on your desktop and select properties<br />
2 Click the Advanced Tab<br />
3 Click the Environment Variables button<br />
4 Under System Variable, click New<br />
5 Enter the variable name as JAVA_HOME<br />
6 Enter the variable value as the install path for the Development Kit<br />
7 Click OK<br />
8 Click Apply Changes<br />
<br />
FOR LINUX:<br />
<a name='more'></a><br />
~/.bash_profile is a startup script which generally runs once. This particular file is used for commands which run when the normal user logs in. Common uses for .bash_profile are to set environment variables such as PATH, JAVA_HOME, to create aliases for shell commands, and to set the default permissions for newly created files.<br />
Set JAVA_HOME / PATH for single user<br />
<br />
Login to your account and open .bash_profile file<br />
$ vi ~/.bash_profile<br />
Set JAVA_HOME as follows using syntax export JAVA_HOME=<path-to-java>. If your path is set to /usr/java/jdk1.5.0_07/bin/java, set it as follows:<br />
export JAVA_HOME=/usr/java/jdk1.5.0_07/bin/java<br />
Set PATH as follows:<br />
export PATH=$PATH:/usr/java/jdk1.5.0_07/bin<br />
Save and close the file. Just logout and login back to see new changes:<br />
$ echo $JAVA_HOME<br />
$ echo $PATH<br />
Tip: Use the following command to find out exact path to which java executable under UNIX / Linux:<br />
$ which java<br />
</path-to-java></div>rykerhttp://www.blogger.com/profile/09840113935914533757noreply@blogger.com0tag:blogger.com,1999:blog-1486143478873334270.post-33938848263039529842011-08-20T20:34:00.000-07:002011-08-20T20:36:56.059-07:00core java interview questions<div dir="ltr" style="text-align: left;" trbidi="on"><ul><span style="font-family: verdana; font-size: 11px;">
<li> <a href="http://www.coolinterview.com/interview/17987/" style="text-decoration: none;" target="_blank"> <b>What is a local, member and a class variable?</b></a> <br />
<span style="color: green; font-family: Verdana; font-size: xx-small;"> </span><br />
<br />
</li>
<li> <a href="http://www.coolinterview.com/interview/17988/" style="text-decoration: none;" target="_blank"> <b>What modifiers are allowed for methods in an Interface?</b></a> <br />
<a href="http://www.coolinterview.com/interview/17988/" style="text-decoration: none;"> <span style="color: green; font-family: Verdana; font-size: xx-small;"> </span></a><br />
<br />
</li>
<li> <a href="http://www.coolinterview.com/interview/17990/" style="text-decoration: none;" target="_blank"> <b>Why operator overloading is not there in java?</b></a> <br />
<a href="http://www.coolinterview.com/interview/17990/" style="text-decoration: none;"> <span style="color: green; font-family: Verdana; font-size: xx-small;"> </span></a><br />
<a name='more'></a><br />
</li>
<li> <a href="http://www.coolinterview.com/interview/17991/" style="text-decoration: none;" target="_blank"> <b>What modifiers are allowed for methods in an Interface?</b></a> <br />
<a href="http://www.coolinterview.com/interview/17991/" style="text-decoration: none;"> <span style="color: green; font-family: Verdana; font-size: xx-small;"> </span></a><br />
<br />
</li>
<li> <a href="http://www.coolinterview.com/interview/17992/" style="text-decoration: none;" target="_blank"> <b>What does it mean that a method or field is “static�?</b></a> <br />
<a href="http://www.coolinterview.com/interview/17992/" style="text-decoration: none;"> <span style="color: green; font-family: Verdana; font-size: xx-small;"> </span></a><br />
<br />
</li>
<li> <a href="http://www.coolinterview.com/interview/17993/" style="text-decoration: none;" target="_blank"> <b>What are wrapped classes?</b></a> <br />
<a href="http://www.coolinterview.com/interview/17993/" style="text-decoration: none;"> <span style="color: green; font-family: Verdana; font-size: xx-small;"> </span></a><br />
<br />
</li>
<li> <a href="http://www.coolinterview.com/interview/17994/" style="text-decoration: none;" target="_blank"> <b>What is a local, member and a class variable?</b></a> <br />
<a href="http://www.coolinterview.com/interview/17994/" style="text-decoration: none;"> <span style="color: green; font-family: Verdana; font-size: xx-small;"> </span></a><br />
</li>
<li> <a href="http://www.coolinterview.com/interview/17995/" style="text-decoration: none;" target="_blank"> <b>What is transient variable?</b></a> <br />
<a href="http://www.coolinterview.com/interview/17995/" style="text-decoration: none;"> <span style="color: green; font-family: Verdana; font-size: xx-small;"> </span></a><br />
<br />
</li>
<li> <a href="http://www.coolinterview.com/interview/17996/" style="text-decoration: none;" target="_blank"> <b>What do you understand by Synchronization?</b></a> <br />
<a href="http://www.coolinterview.com/interview/17996/" style="text-decoration: none;"> <span style="color: green; font-family: Verdana; font-size: xx-small;"> </span></a><br />
<br />
</li>
<li> <a href="http://www.coolinterview.com/interview/17998/" style="text-decoration: none;" target="_blank"> <b>What is Collection API?</b></a> <br />
<a href="http://www.coolinterview.com/interview/17998/" style="text-decoration: none;"> <span style="color: green; font-family: Verdana; font-size: xx-small;"> </span></a><br />
<br />
</li>
<li> <a href="http://www.coolinterview.com/interview/17999/" style="text-decoration: none;" target="_blank"> <b>What is similarities between an Abstract class and Interface?</b></a> <br />
<a href="http://www.coolinterview.com/interview/17999/" style="text-decoration: none;"> <span style="color: green; font-family: Verdana; font-size: xx-small;"> </span></a><br />
<br />
</li>
<li> <a href="http://www.coolinterview.com/interview/18000/" style="text-decoration: none;" target="_blank"> <b>What is difference between an Abstract class and Interface?</b></a> <br />
<a href="http://www.coolinterview.com/interview/18000/" style="text-decoration: none;"> <span style="color: green; font-family: Verdana; font-size: xx-small;"> </span></a><br />
<br />
</li>
<li> <a href="http://www.coolinterview.com/interview/18001/" style="text-decoration: none;" target="_blank"> <b>How to define an Abstract class?</b></a> <br />
<a href="http://www.coolinterview.com/interview/18001/" style="text-decoration: none;"> <span style="color: green; font-family: Verdana; font-size: xx-small;"> </span></a><br />
<br />
</li>
<li> <a href="http://www.coolinterview.com/interview/18002/" style="text-decoration: none;" target="_blank"> <b>How to define an Interface?</b></a> <br />
<a href="http://www.coolinterview.com/interview/18002/" style="text-decoration: none;"> <span style="color: green; font-family: Verdana; font-size: xx-small;"> </span></a><br />
<br />
</li>
<li> <a href="http://www.coolinterview.com/interview/18003/" style="text-decoration: none;" target="_blank"> <b>Explain the user defined Exceptions?</b></a> <br />
<a href="http://www.coolinterview.com/interview/18003/" style="text-decoration: none;"> <span style="color: green; font-family: Verdana; font-size: xx-small;"> </span></a><br />
<br />
</li>
<li> <a href="http://www.coolinterview.com/interview/18004/" style="text-decoration: none;" target="_blank"> <b>Explain garbage collection?</b></a> <br />
<a href="http://www.coolinterview.com/interview/18004/" style="text-decoration: none;"> <span style="color: green; font-family: Verdana; font-size: xx-small;"> </span></a><br />
<br />
</li>
<li> <a href="http://www.coolinterview.com/interview/18005/" style="text-decoration: none;" target="_blank"> <b>Describe the principles of OOPS.</b></a> <br />
<a href="http://www.coolinterview.com/interview/18005/" style="text-decoration: none;"> <span style="color: green; font-family: Verdana; font-size: xx-small;"> </span></a><br />
<br />
</li>
<li> <a href="http://www.coolinterview.com/interview/18006/" style="text-decoration: none;" target="_blank"> <b>Explain the Encapsulation principle.</b></a> <br />
<a href="http://www.coolinterview.com/interview/18006/" style="text-decoration: none;"> <span style="color: green; font-family: Verdana; font-size: xx-small;"> </span></a><br />
</li>
<li> <a href="http://www.coolinterview.com/interview/18007/" style="text-decoration: none;" target="_blank"> <b>Explain the Inheritance principle.</b></a> <br />
</li>
<li> <a href="http://www.coolinterview.com/interview/18008/" style="text-decoration: none;" target="_blank"> <b>Explain the Polymorphism principle.</b></a> <br />
<a href="http://www.coolinterview.com/interview/18008/" style="text-decoration: none;"> <span style="color: green; font-family: Verdana; font-size: xx-small;"> </span></a> </li>
</span></ul></div>rykerhttp://www.blogger.com/profile/09840113935914533757noreply@blogger.com0