Tuesday, January 8, 2013

How to Use Cloud Computing for a Business and Home?


Cloud computing offers many benefits in both home and office settings. Cloud services provide
a secure way of storing large amounts of data. Information can be shared between individuals or
companies and the networks can be made either public or private depending on the nature of the
information stored. Cloud servers offer a variety of packages to meet the needs of families and
businesses of various sizes.

While many families do not need the vast amounts of storage cloud computing offers, the
security it provides can protect important medical documents and insurance information.
Businesses, on the other hand, need the capability for ever increasing amounts of storage as well
as proven security features that protect their confidential information. Family and business have
various needs that can be met using cloud computing services tailored specifically for them.

Getting started is as easy as contacting a cloud service. Many offer trial periods so customers can
create a service and after a specific amount of time (normally 30 to 90 days) can decide whether
or not they want to sign on for a long term contract. If they do not like the service, they retrieve
their information and move on to the next company. If they do choose to continue with the cloud
service, they agree to a specific time period. They fine tune the package they have created and
agree to pay by the month, semi-annually or annually, depending on their needs.

JavaScript - How to get random numbers and random alpha-numeric numbers?


In this article we will see how to generate random numbers and alpha-numeric numbers in JavaScript  We will use JavaScript Math.random function to generate random numbers.

Math.random function returns a floating-point, pseudo-random number in the range [0, 1) that is, from 0 (inclusive) up to but not including 1 (exclusive), which you can then scale to your desired range.

Please see the below function.


1. Get random numbers

//get random numbers
function getRandomNumber() {
var max = 10;
var randomnumber = Math.floor(Math.random()*max)
return randomnumber;
}

2. Get random numbers between minimum and maximum range

//get random numbers between minimum and maximum range
function getRandomNumber() {
var min = 10;
var max = 20;
var randomnumber = Math.floor((Math.random()*(max - min + 1))+min);
return randomnumber;
}


Monday, January 7, 2013

Java - Various ways to iterate a Map (Hashtable, HashMap, TreeMap, LinkedHashMap)


A Map is collection that maps keys to values. A map cannot contain duplicate keys, each key can map to at most one value. Map comes with 4 different version - Hashtable, HashMap, TreeMap, LinkedHashMap.

Hashtable - Key methods of Hashtable are synchronized. Hashtable doesn't allow a null key or null values.

HashMap - HashMap allows one null key and multiple null values in a collection.

TreeMap - TreeMap is a sorted Map.

LinkedHashMap - LinkedHashMap maintains insertion order.

Below are the methods in which you can iterate a Map.

1. Iterator - Using Iterator you can iterate HashMap, TreeMap, LinkedHashMap.

2. Enumeration - Using Enumeration you can iterate Hashtable.

3. Also you can iterate values of a Map using values() and elements() method.

Java - Various ways to iterate a Set


A Set is a collection that contains no duplicate elements. Below are the methods in which you can iterate a Set

1. For each loop (introduced from Java 5)
2. Array and While loop (here you can use for loop as well)
3. Using Iterator

Please see the below code.

Different type of ways to iterate a List in java


As List is dynamically growable array. Below are the methods in which you can iterate a List

1. Basic for loop
2. For each loop (introduced from Java 5)
3. While loop
4. Using Iterator
5. Using ListIterator (Unlike Iterator which traverse list in forward direction, ListIterator is used to traverse the list in either direction)

Please see the below code.