View RSS Feed

Most Popular Blogs

  1. The Five Tiers in Java EE

    by , 11-19-2011 at 06:57 PM (My Java Tips)
    This post briefly explains the 5 tiers in Java Enterprise Edition.


    A web browser, a hand held device or an application which remotely accesses the services of an enterprise application are examples of a Client tier. In other words a Client tier can consists of all the types of components that are clients of an enterprise application.


    Filters, Java Servlets, JavaServer Pages, JavaBeans and other utility classes ...
  2. A recursive method for searching an array of integers...

    by , 03-08-2012 at 09:49 PM
    Java Code:
    public class ArrayLister {
    	private static int arraySearcher(int[] arrayToSort,int numberToFind,int left,int right){
    		int middle = (left + right) / 2 ;
    			if(arrayToSort[middle] == numberToFind) {
    				return middle;
    				return -1;
    		if(arrayToSort[middle] == numberToFind) {
  3. The Singleton pattern

    by , 08-12-2011 at 04:29 AM
    In mathematics a singleton (not to be confused with a simpleton) is a set with exactly one element.
    In computer science Singleton is a pattern which enforces the existence of only up to one instance of a class.

    Singleton is sometimes considered an anti-pattern, and it's famous for being considered unnecessary in the world of Python (where you duck type).
    Singleton is however useful, it is a nice and clean why to restrict the number of instances, to only one.
    In ...

    Updated 08-12-2011 at 06:13 PM by Hibernate (typo)

  4. Decorator Pattern Example

    by , 03-03-2012 at 10:27 PM
    Java Code:
    package decoratorPattern;
    public abstract class Beverage {
    	String description;
    	int size;
    	public Beverage(int size) {
    		this.size = size;
    	public String getDescription() {
    		String mySize = null;
    		if(size == 1)
    			mySize = "Small";
    		else if(size==2)
    		else if(size==3)
  5. Using the Observable - Observer class , interface in JAVA. Observer Pattern example.

    by , 03-03-2012 at 11:00 PM
    Java Code:
    package observerPatternBuiltIn;
    import java.util.Observable;
    public class MyObservable extends Observable {
    	int integerToBeObserved;
    	public void setInt(int i) {
    		integerToBeObserved = i;
    	public int getInt() {
    		return integerToBeObserved;
    package observerPatternBuiltIn;
  6. java (7) equivalent of .Net timespan

    by , 07-28-2012 at 07:03 AM
    Quote Originally Posted by .paul. View Post
    i used Dates in this particular case, as they were better suited to the application.

    but i also created a java TimeSpan class, similar to the .Net Framework TimeSpan class:

    Java Code:
    package javaTimeSpans;
     * @author Paul
    public class TimeSpan {
        private int _days;
        private int _hours;
        private int _minutes;
        private int _seconds;
        public int Days(){
  7. Create SQL File in Eclipse

    by , 05-21-2011 at 10:03 PM (My Java Tips)
    SQL files can be created manually in any existing eclipse project. It's simple and useful. I'll list the required steps.

    • Open Database Development perspective
    • Select File > New > Other, expand SQL Development, select SQL File, and click Next
    • This will open the New SQL File wizard.
    • To create a new project, click "Create Project" and follow the wizard instructions. Now provide the SQL file name.
    • Select a connection profile type from the Connection profile
    Tags: eclipse, sql Add / Edit Tags
  8. XML Prolog

    by , 11-01-2011 at 06:15 PM (My Java Tips)
    Developer who are working with XML, should know about XML prolog. This post will brief you about the said topic.

    Its an optional component of the XML document. If you wish to include it, then it must appear before the root element. A prolog consists of two parts:

    Part 1 comprises of XML declaration
    Part 2 comprises of Document Type Declaration (DTD)

    You can include both depending on your needs.


    <!--?xml ...
  9. Unary operators

    by , 11-02-2011 at 07:09 PM (My Java Tips)
    I will present an an example that will show the use of following uniary operators: Unary minus operator, Increment operator, Decrement operator, Logical compliment operator

    Unary plus operator (+) indicates positive value. This (+) operator is used to perform a type conversion operation on an operand. The type of the operand must be an arithmetic data type i.e. if a value of the integer operand is negative then that value can be produced as a positively applying unary plus (+) operator. ...
    Java SE
  10. Example - HashMap

    by , 11-02-2011 at 07:11 PM (My Java Tips)
    Map is an object that stores key/volume pairs. Given a key, you can find its value. Keys must be unique, but values may be duplicated. The HashMap class provides the primary implementation of the map interface. The HashMap class uses a hash table to implementation of the map interface. This allows the execution time of basic operations, such as get() and put() to be constant.

    This code shows the use of HaspMap. In this program HashMap maps the names to account balances.
    Java SE
  11. LinkedList (Generics)

    by , 11-03-2011 at 01:07 PM (My Java Tips)
    Like Vectors and ArrayLists, LinkedList can also be made to deal with only one type of objects. Lets see how to do that.

    Java Code:
    LinkedList ll = new LinkedList();
    The LinkedList named ll can only store String objects. This is very useful and provides more control over collection. You are always sure that you will get objects of a specific type from the list. ...
    Java SE
  12. Object Pointer In Java

    by , 11-08-2011 at 06:43 PM (My Java Tips)
    Pointer in C/C++ denotes to the variables saving the reference, In Java there is only call by reference. But here the pointer refers to an object which itself has another reference within it.

    Java classes can have instance variables. If an instance variable is of class type, then it can hold instance of the class in it. This is called pointer to the object.

    In some cases, we need an object that contains an instance variable that can refer to another object of the same ...
    Java SE
  13. Tracking Class Loading and Garbage Collection

    by , 11-08-2011 at 07:41 PM (My Java Tips)
    When any Java program runs, In background some libraries are loaded by JVM (Java Virtual Machine) in order to execute the Java program. Java command line tool(”java”) has various options that might be helpful for a Java programmer to know more about the class loading mechanisms.

    For example “ –cp “ option that instructs JVM to find necessary classes other than system classes. An usage is shown below

    java -cp ExampleDir.ExampleTipIf ExampleTip.class is not found in ExampleDir ...
    Tags: command line, jvm Add / Edit Tags
    Java SE
  14. Plugin project - Overview page

    by , 11-17-2011 at 07:30 PM (My Java Tips)
    This post is about the overview page for plugin project.

    The Overview page is designed to be a quick reference on how to develop, test and deploy a plug-in. It is also a navigational center where you can follow the hyperlinks to navigate a particular page or execute a particular command.

    Plugin overview

    The Plug-in Content section explains the structure and content ...
  15. GPS location / Cell id / Placing a call

    by , 11-22-2011 at 06:16 PM (My Java Tips)
    This post presents miscellaneous tasks that you can do in your J2ME application.

    Firstly, how to get GPS location. javax.microedition.location.Location provides support for this. Review the snippet below:

    Java Code:
    LocationProvider loc = LocationProvider.getInstance(null);
    Location location = loc.getLocation(60*3);
    String lat = location.getQualifiedCoordinates().getLatitude();
    String lon = location.getQualifiedCoordinates().getLongitude();
Page 2 of 4 FirstFirst 1234 LastLast