Raj Bhunia

Greenhorn
+ Follow
since Apr 10, 2011
Raj likes ...
Netbeans IDE Java
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
1
Received in last 30 days
0
Total given
1
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Raj Bhunia

Hi All,

I wanted to know - how is the demand of portal developer (more specifically liferay portal) in India ?

Thanks,

Raj

9 years ago
Can anybody please suggest me why does the below code throws a IndexOutOfBoundsException :


Output :
9 years ago

Rahul Sudip Bose wrote:
I am not clear about utility methods.


Imagine you have a class that have a method and it always run in the same way , it's sole purpose is to return some thing ,doesn't matter which instance of that class perform that method.These type of methods are called utility methods.Utility methods are static methods.For example ,Math class has several utility methods like random(),exp(double),log(double)
etc.We don't need create an instance of Math class( you can't create an instance of Math class because it has private constructor).Use these methods by using class name only.
10 years ago

Rahul Sudip Bose wrote:
how the database program is using one instance to save memory



Lets test that database code......


and the output of that code is : Same reference......

The reason is when ever the ConnectionUtil class is loaded into the memory that static block is initialized and connection object is created.How many objects you create it doesn't matter , same reference will be given to every object .
10 years ago
Singleton pattern is a popular design pattern which proposes that only one instance of a class will be created by JVM.Repeated calls always return the same instance.When programmers need to be concerned about meaningful use of resource then use this pattern.For example ,if programmers create a new connection object every time it requires , then clearly it is a wastage of resource.In this case we can create a singleton connection class and that single connection object will be used throughout the application.



If you need connection object just use it like this....


Another example where singleton is used frequently is in hibernate when you instanciate SessionFactory.Because SessionFactory is very resource intensive.So instanciate it only once.


I hope this will help you.For more info go to this link Singleton Pattern
10 years ago
Static methods are useful for creating utility classes.Because utility classes are not meant to be instanciated.Like java.lang.Math class.

Static methods are also useful for creating singletons , factory methods.
10 years ago
When we should use serialization?
10 years ago
What is decorator design pattern ? What are the advantages of decorator design pattern?
10 years ago