Menu

Category Archives: JAVA

Post navigation

Today’s application expects access of all business in enterprise environment regardless of application technologies, which require, seamless integration with desperate systems.
This integration can be achieved through wiring of desperate systems using Middleware technologies. Continue reading →

Web page designs are becoming innovative with rich interface which involve extra code such as java scripts, css, and images etc. Most of the end-user response time tied-up in downloading these components.Optimizations of number of http requests and response size are the key parameters to improve the web application performance. Continue reading →

While declaring the class member variables we have to be very confident about the behavior of the member variables. For example some variable are constant and will be same across the class life cycle and some are instance variables which will be tightly bind with the object (instance) of the class.

Always use the static for the member variable which doesn’t change across the objects of the class.

I would try to check the performance using the below code sample:

publicclass TestClassVariable {

public TestClassVariable() {

// do nothing

}

public String country[] = { “India”, “USA”, “China”, “UK” };

publicstaticvoid main(String s[]) {

long start, end;

int[] a = newint[1000000];

start = System.currentTimeMillis();

for (int j = 0; j length; j++) {

TestClassVariable tstClassVar = new TestClassVariable();

}

end = System.currentTimeMillis();

System.out.println(end – start + ” “

+ ” milli seconds execution time”);

}

}

Result: 94 milli seconds execution time

In the above code we used country as class instance variable and it takes 94MS but as we know country could be make as static member variable because it will be not going to change across the instances so the correct way to use as static member variable.

So we can change the program slightly and see the figures again

publicclass TestClassVariable {

public TestClassVariable() {

// do nothing

}

publicstaticStringcountry[] = { “India”, “USA”, “China”, “UK” };

publicstaticvoid main(String s[]) {

long start, end;

int[] a = newint[1000000];

start = System.currentTimeMillis();

for (int j = 0; j length; j++) {

TestClassVariable tstClassVar = new TestClassVariable();

}

end = System.currentTimeMillis();

System.out.println(end – start + ” “

+ “milli seconds execution time”);

}

}

Result: 16 milli seconds execution time

We could easily figure it out the performance get enhance 6 times then the original one