Skip to main content

Posts

Showing posts from July, 2010

HTML5 Web SQL Database

HTML5 has a bunch of cool APIs. In one of my previous posts, I have written a simple demonstration of the Web Storage JavaScript API. In this post I will be showing another demonstration, the Web SQL Database JavaScript API. What is so fascinating about these APIs is they are “crash-safe.” Now you can lessen the load of your web servers and perform SQL tasks like, sorting, joining, etc. on the client side. Click [here] for the demonstration.

Removing while Iterating a Collection in Java

Let us say you have a list and you want to remove items while iterating through it if a certain condition satisfies. for (Object object : listOfObjects) { if (isConditionSatisfied) { listOfObjects.remove(object); } } What is wrong with this code above? Try it and you will get this, Exception in thread "main" java.util.ConcurrentModificationException You might want to do this instead, Iterator<Object> iterator = listOfObjects.iterator(); while (iterator.hasNext()) { Object object = iterator.next(); if (isConditionSatisfied) { iterator.remove(); } } Have a nice day.

HTML5 Web Storage

Here is a simple demonstration of HTML5’s Web Storage. The code is quite straightforward. One thing to experiment is after entering any string and hitting save, try closing the browser entirely and opening it again visiting the same page to see if the data persisted. Click [here] for the demonstration.