Posts

Java 6 Collections: Why use LinkedList

Image
Java collections framework avoid the idiosyncratic programming. Therefore, collection framework is more manageable and usability is unified across the applications, and best practices are enforced. Anyway, it is very important to understand the generics based new collection framework. I love to do programming with Eclipse. As shown in the above figure, the instance variable ‘d’ can be initialized with with the ‘ArrayList’ whose parameterized type is ‘Dog’. The type of the instance variable d is ‘List’ which is also based on ‘Dog’ generic type. To this array you can add only instances which are type of ‘Dog’. If the generic type is changed to ‘Integer,’ everything will change from ‘Dog’ to ‘Integer’. If you are comfortable with Java Generics, this is the time to consider that how they have implemented Collection to cater for any Object. Linked List Array and her counterpart ArrayList has direct access which cost Ο(1) time . Comparably, this is the cheapest. However, arra...

Java Thread Interaction: use of wait and notify

In this blog, my main intention to introduce the thread interaction based on the java.lang.wait() and java.lang.notify()/notifyAll() methods. Anyway, I would keen to keep the things simple. It is not difficult to visualize one of the playground trainings you had participated. There is one trainer and number of players. All the players are waiting for the ball which has been thrown by the instructor. One person can acquire ball at once and he will re-throws the ball back to the trainer. To make the things simple, suppose a player, who acquired the ball, has been pulled out from the field. For the design, we have two factors to model The behavior between Trainer and the players The ownership of the ball In the first case players are waiting for the trainer’s notification to acquire the ball, anyway in this competition thread scheduler decide who should get the ball, mean no special priority (all the Player threads are in the same priority level). To win the competition at...

Example for boolean java.lang.Thread.isAlive()

Image
This blog intended to check the aliveness of a thread. We have used the method boolean isAlive()  define in the class java.lang.Thread, which is not a static method. Aliveness of the thread can be noted in the Thread lifecycle diagram as follows.   I wrote a simple example to demonstrate the status of the aliveness of the Thread. In that program, aliveness tested before start, that is where the thread is in the New state, before end (Runnable, Running, or Blocked) and after end which is Dead status. The AliveExample thread is blocked while main thread is running, although it is alive. package com.ojitha.thread; enum Alive { YES(" thread is alive"), NO(" thread is not alive"); private String msg; private Alive(String msg){ this.msg = msg; } public String getMessage(){ return this.msg; } } public class TestAlive { /** * @param args */ public static void main(String[] args) { AliveExample a = new AliveExample(); Thread t...

Java Constructor Loading Tips

This is very interesting topic to discuses Java constructor loading. As a Java programmer, unfortunately, I haven't had a chance to go through in my experience because most of the time standard programming doesn't use this. However, it is very important to know that how the JVM load static/instance blocks and variables with the constructor in the initiation of new objects. I've wrote very simple program to illustrate this scenario. public class Constructors { public static int count=0; public static void main(String[] args){ System.out.println("["+ ++Constructors.count +"]"+"Instantiate"); ChildClass c = new ChildClass(); } } //super class class SuperClass { //super class instance variable int varS =++Constructors.count; SuperClass(){ System.out.println("["+ ++Constructors.count +"]"+...

2009 Top 10s

With the start of 2009, lots of good reviews of previous year as well as predictions for this year have been released. This blog amass the top 10s I found from different locations. 10 Java Technology Resolution for 2009 InformIT most popular 2008 list Interview with Donald Knuth How to Network Vista and XP Computers Together C++ Reference Guide The Top 10 iPhone Applications .NET Reference Guide SQL Server Reference Guide Java Reference Guide The Top 10 Problems with IT Certification in 2008 Looking Inside Microsoft System Center Operations Manager 2007 Microsoft Office Reference Guide " What’s Hot for 2009? " from IEEE Computer Society 10 predictions for Linux and open source in 2009 IBM Developerworks top 10 contents

Best 10 Windows programs

I've used Linux as well as Windows. There are thousand of free software utilities for Linux platform which always make my life easier. I was wonder whether there is comprehensive enough tools which can support Windows in some difficult occasions. Recently, I found very good blog " My 10 favorite Windows programs of all time ". These tools are very interesting.

Semantic Web in use

Up coming Web 3.0 which is the semantic web will enable the web to be more interactive and rewarding because things described in semantic languages are computer understandable. But widespread adoption of the semantic web is still a long way off. With the current web, the main problem is 'information overload' which is not possible to mitigate even in the web 2.0 era. Therefore, it is obvious that a new form artificial intelligence is should be embark on the Internet to overcome the problem of 'information overload' in the future web 3.0. The idea of the semantic web is very simple, that is things on the Internet will be described in computer understandable languages. This language should understand an object on its attributes. For example, if you surfing for 'fox' animal, in google your first result would be Fox news channel rather animal. Moreover, there can be man named with 'Fox'. Indeed, if an object might be a marked as a animal, an enormous netwo...