Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Interview-Questions singleton java implementation
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


sankhamita
singleton java implementation
1 Answer(s)      6 years and 7 months ago
Posted in : Java Interview Questions


What is Singleton? And how can it get implemented in Java program?


Advertisement
View Answers

March 17, 2008 at 9:04 PM


Singleton is used to create only one instance of an object that means there would be only one instance of an object in the whole application.

Example of Singleton Class in JAVA

Singleton.java
- - - - - - - -

public class Singleton{

private static volatile Singleton instance;
private Singleton() {}

public static Singleton getInstance(){
if(instance == null)
synchronized(Singleton.class) {
if (instance == null)
instance = new Singleton();
}
return instance;
}
public static void main(String args[]){
Singleton singleton = Singleton.getInstance();
System.out.println("Hello singleton");
}
}

- - - - - - - - - - -
Resource of singleton class in Java
http://www.roseindia.net/help/java/s/singleton-class.shtml

- - - - - - - -
;) Meeya


Related Tutorials/Questions & Answers:
Java singleton
Java singleton  What is singleton
singleton - Java Interview Questions
singleton  what is singleton class.give one example of implementation of singleton class?  hi friend, import java.io.*; public class SingletonExam implements Serializable { public static SingletonExam single
Advertisements
Java Singleton Pattern
In this section, you will learn about singleton pattern in Java
What is singleton? - Java Beginners
What is singleton?   Hi, I want to know more about the singleton in Java. Please explain me what is singleton in Java? Give me example of Singleton class. Thanks   hello, Singleton is a concept in which you
singleton pattern - Java Beginners
singleton pattern  how i use singleton pattern in my web aplication project.plz give an example.its urgent
What is an efficient way to implement a singleton pattern in Java?
What is an efficient way to implement a singleton pattern in Java?  What is an efficient way to implement a singleton pattern in Java
singleton class in struts - Java Beginners
singleton class in struts  hi, This balakrishna, I want to retrive data from database on first hit to home page in struts frame work
singleton class in struts - Java Beginners
singleton class in struts  hi, This balakrishna, I want to retrive data from database on first hit to home page in struts frame work
singleton class in struts - Java Beginners
singleton class in struts  hi, This balakrishna, I want to retrive data from database on first hit to home page in struts frame work
singleton class in struts - Java Beginners
singleton class in struts  hi, This balakrishna, I want to retrive data from database on first hit to home page in struts frame work
Java singleton program - Java Interview Questions
Java singleton program  Hi All, Can you please explain me in brife with an example how the singleton program works, i did see some documents but was not able to unerstand except one object can be used. this was a java
java native implementation
java native implementation  What is java native implementation
How singleton in struts - Java Interview Questions
How singleton in struts  Hi, How to implement singleton and threadsafe in struts . same in jsp and servlet. Thanks Prakash
filter implementation in java
filter implementation in java   How to implement filters in java?   Java - filter implementation Tutorials Filter Files in Java Response Filter Servlet Example
java interfaces implementation
java interfaces implementation  hai I have defined one inter face... different implementation classes for add() method and sub()and mul() when i trying... which are define in Maths interface. I want only addition implementation
Question in Array Implementation (java) ??!
Question in Array Implementation (java) ??!  Good Morning EveryOne I have Q in Java - and if any One have the Answers please tall me ??!! Question is : 1- Create a class called ‚??PhoneEntry‚?? which can be used to store
Java implementation problem
Java implementation problem  I want to implement following in java code : Main thread 1. create three threads 2. wait for completion of stage 2.../answers/viewqa/Java-Beginners/28578-java-implementation-problem-.html
java implementation - Java Beginners
java implementation  Im M.Phil research scholar,i need a software testing module implemented in java.My research area is software testing,if anyone could help me out
java implementation problem
java implementation problem   I want to implement following in java code : Main thread Create three threads wait for completion of stage 2 of all three threads Access all three local variable (LC0, LC1, LC2) of threads bulid
singleton class
singleton class  What is singleton class
garbage collection implementation dependent java
garbage collection implementation dependent java  How a garbage collection works in Java
where singleton class used in java - Java Interview Questions
where singleton class used in java  where singleton classes are used in j2ee web application.can we use it for connection pooling. Thanks Prakash
Progress Bar implementation in Java Script
Progress Bar implementation in Java Script  Hi Friend, I am new to Java Script, but i want implement the progress bar in my html by reading the value from file (like value=30) and the value in file be changing from 0 to 100
java code implementation - Java Beginners
java code implementation  I am writing a java program, voteCounter the program is in two classes; one is the main class, voteCounter.java, and the other is voteCounterPanel.java. what it basically does is when the user presses
linked lists implementation - Java Beginners
, there are no preconditions. Write the code for the method for a linked implementation (without tail
Singleton in Flex
Singleton in Flex  hi..... please tell me about How can you implement Singleton in Flex Application? please give me the procedure so i can implement....... Thanks
Stack Implementation java code - Java Beginners
Stack Implementation java code  Hello roseindia and java experts can u help me.can you give me a code for this sir/maam.thank you so much. STACK IMPLEMENTATION -expression evaluator *GIVEN a String of expression, create
singleton program
singleton program  import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.Scanner; public class Emp{ public
J2EE Singleton Pattern - Design Pattern Tutorials
J2EE Singleton Pattern Singleton Design Pattern This design pattern governs the object instantiation of Object in Java. This design pattern is used when only one instance of object is required. The Constructor in a Singleton class
Simple Hash Table implementation in Java
Simple Hash Table implementation in Java   ... implementation from the basic in Java. In this section, you will see how... the given title exists or not. This section is very helpful for your java
 

 

 

DMCA.com