Showing posts from December, 2006

Java 5 Feature: An intro to foreach

Looping is a control structure that has been around ever since we started programming. The good old syntax for looping that you would have used most often is:

String[] messages = {"Hello", "Greetings", "Thanks"};
var length = messages.length;
var int i = 0;
for(i = 0; i < length; i++){

What if you want to iterate over a collection, like ArrayList? We will do something like:

Iterator iter = lst.iterator();
for(;iter.hasNext();) {

The foreach was introduced to avoid introduction of any new keywords. The foreach introduced in Java 5 simplifies looping further. Let’s take a look at an example of how we can use the new way to loop:

for (String msg : messages) {

You would read
for (String msg : messages)
as "foreach String msg in messages". Within the loop of foreach, msg represents a String element within the array String[].
Instead of inventing another keywo…

Java 5 Feature: An intro to Autoboxing

With Java 5 (or Java 1.5 or JSE 5.0 or Java J2SE 5.0 or JDK 1.5), a new feature called Autoboxing has been introduced to the language. it is the automatic conversion of the primitives and wrapper objects.
Boxing is to place a primitive data-type within an object so that the primitive can be used like an object. For example, a List, prior to JDK 1.5, can't store primitive data types. So, to store int type data in a List, a manual boxing was required (i.e from int to integer). Similarly, to retrieve the data back, an unboxing process was required to convert Integer back to int.
Autoboxing is the term for treating a primitive type as an object type. The compiler automatically supplies the extra code needed to perform the type conversion. For example, in JDK 1.5, it now allows the programmer to create an ArrayList of ints. This does not contradict what was said above for List: the ArrayList still only lists objects, and it cannot list primitive types. But now, when Java expects an objec…

Google Browser Sync

Google Browser Sync for Firefox is an extension that continuously synchronizes your browser settings - including bookmarks, history, persistent cookies, and saved passwords - across your computers. It also allows you to restore open tabs and windows across different machines and browser sessions.
Please note: Google Browser Sync must update your browser settings whenever you start Firefox. This will increase the start-up time of Firefox (the time between clicking on the Firefox icon and loading your start page) - please bear with us as we work to decrease this delay.

How to Use
To use Google Browser Sync, simply install and configure the extension on all computers for which you'd like your browser settings automatically kept in sync. Even if you only install Browser Sync on a single computer, you can use it to backup your browser settings and to restore your open tabs and windows across browser sessions.

Configuring your computers
After successfully downloading and installing the exten…

To Ruby From Java - Similarities and Differences

Came through this interesting post comparing Java with Ruby. Java is mature. It's tested. And it's fast (contrary to what the anti-Java crowd may still claim). It's also quite verbose. Going from Java to Ruby, expect your code size to shrink down considerably. You can also expect it to take less time to knock together quick prototypes.SimilaritiesAs with Java, in Ruby... Memory is managed for you via a garbage collector.Objects are strongly typed.There are public, private, and protected methods.There are embedded doc tools (Ruby's is called RDoc). The docs enerated by RDoc look very similar to those generated by javadoc.DifferencesUlike Java, in Ruby... You don't need to compile your code. You just run it directly.There are different GUI toolkits. Ruby users can try WxRuby, FXRuby, Ruby-GNOME2, or the bundled-in Ruby Tk for example.You use the end keyword after defining things like classes, instead of having to put braces around blocks of code.You have require …

HtmlUnit - unit testing framework for web applications

HtmlUnit is a java unit testing framework for testing web based applications. It is similar in concept to httpunit but is very different in implementation. Which one is better for you depends on how you like to write your tests.
HttpUnit models the http protocol so you deal with request and response objects. HtmlUnit on the other hand, models the returned document so that you deal with pages and forms and tables.

HtmlUnit is not a generic unit testing framework. It is specifically a way to simulate a browser for testing purposes and is intended to be used within another testing framework such as JUnit.

Support for the HTTP and HTTPS protocols. ( JSSE must be in your classpath in order to use HTTPS support)
Support for cookies
Ability to specify whether failing responses from the server should throw exceptions or should be returned as pages of the appropriate type (based on content type)
Support for submit methods POST and GET
Ability to customize the request headers being sent to th…

Helipad - The flexible web notepad

Helipad is a web-based tool, which means you can use it wherever you can get online.

Since Helipad is a hosted application, we do all the boring stuff: backup documents, maintain security, upgrade software, while you're left to do the most important thing: write.
Write notes and organize them with tagsCreate and maintain to-do listsDraft documents on any computer or phone with Internet accessShare your work with others
Unobtrusive auto-save: set a timer to save automatically so youdon't lose your workOrganize your documents with tagsQuickly find documents with a live-search on every pageCustomize your Helipad with themes and pluginsShare your documents with friendsPrepare documents for print by changing fonts
Get more out of Helipad
Helipad works with popular phone web browsers.Your notes look great printed from Helipad.Developers can get more out of Helipad by using the API, or by writing add-ons.


DropBoks is a little website that allows you to securely upload and download your files as you please. No bells, no whistles, just an easy and quick way to store your files online.Each account has 1 GB of storage space available. You can upload and download files (any format) as large as 50 MB.How are we able to keep DropBoks free? We have found that when you offer a
valuable service that is extremely simple to use, folks have no problem making a
small donation. This has covered our costs since day one!