Thursday, May 27, 2010

Tit-Bits

______________________________________________________________________

Synchronizing Hashmap :


private Map values = Collections.synchronizedMap(new HashMap());

----------------------------------------------------------------------------------------

Generate Random numbers :

The below code generates random numbers under 100


Random randomGenerator = new Random();
for (int idx = 1; idx <= 10; ++idx){
int randomInt = randomGenerator.nextInt(100);
log("Generated : " + randomInt);
}


----------------------------------------------------------------------------------------

Generate Random String:


String correlationId = RandomStringUtils.randomAlphabetic(8)


----------------------------------------------------------------------------------------

No comments:

Post a Comment