Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

how to make the double-tone class ? as we have singletone
class..?

Answer Posted / sagar kumar

public class DoubletonTest {
public static void main(String[] args) {
Helloo h1=Helloo.getHello(1);
Helloo h2=Helloo.getHello(2);
Helloo h3=Helloo.FIRST;
Helloo h4=Helloo.SECOND;
System.out.println(h1);
System.out.println(h2);
System.out.println(h3);
System.out.println(h4);
System.out.println(h1==h3);//true
System.out.println(h2==h4);//true

}
}
class Helloo{
private Helloo(){

}
final static public Helloo FIRST=new Helloo();
final static public Helloo SECOND=new Helloo();

static public Helloo getHello(int val){
if (val<1 || val>2) {
throw new IllegalArgumentException(" "+val);
}
if (val==1) {
return FIRST;
}
return SECOND;
}
}

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is args length in java?

1118


Explain treeset?

1049


What is the use of static class?

1084


Does constructor creates the object ?

978


What is the equal sign?

1030


How will you print number in reverse (descending) order in BST.

943


What is 16 bits called?

888


What are the 6 mandatory procedures for iso 9001?

946


What is a class component?

1114


What invokes a thread's run() method in java programming?

1117


How many boolean functions are there?

922


What is the major difference between linkedlist and arraylist?

963


What are keyboard events?

1095


how to deploy tomcatserver to weblogic server? write d following steps?

1913


What are green threads in java?

946