Both ArrayList and HashMap belongs to different Collection class in java.Both of them are used to store objects but their internal working is totally different
. ArrayList Vs HashMap
import java.net.InetAddress;
import java.net.UnknownHostException;
public class FindIpAddress {
/**
* @param args
*/
public static void main(String[] args) {
InetAddress myIp = null;
try {
myIp = InetAddress.getLocalHost();
} catch (UnknownHostException e) {
System.out.println("Exception caught ="+e.getMessage());
}
System.out.println("IP of my system is := "+myIp.getHostAddress());
}
}
1: import java.util.Scanner;
2: public class Prime {
3: /**
4: * @param args
5: */
6: public static void main(String[] args) {
7: int iNumber,iRemainderValue;
8: //Scanner class used for I/O operations
9: Scanner scanner=new Scanner(System.in);
10: System.out.println("Enter the number till which you want to generate prime numbers:");
11: iNumber=scanner.nextInt();
12: //outer loop iterates till iNumber value
13: for(int i=2;i<iNumber;i++)
14: {
15: iRemainderValue=0;
16: //inner loop checks if value of i is divisible by j values and sets the
17: //iRemainderValue value accordingly.
18: for(int j=2;j<i;j++)
19: {
20: if(i%j==0)
21: iRemainderValue=1;
22: }
23: if(iRemainderValue==0)
24: {
25: System.out.print(i +" ");
26: }
27: }
28: }
29: }
Synchronization
|
ArrayList in not synchronized means it is not suitable for multi-threaded environment.
|
Vector is synchronized.
|
Performance
|
Arraylist are faster as it is not synchronized.
|
Vector performance is slow as they are thread safe.
|
Resize
|
ArrayList grow half of its size when resized.
|
Vector grow double of its size when resized.
|
Iteration method
|
ArrayList does not uses enumerator for iteration.
|
Vector uses enumerator for iteration.
|
HashMap is not synchronized.hence It is better for non-threaded applications.
|
||
| The iterator in HashMap is fail fast. | The enumeration in HashTable is not fail fast. |
Ctrl+N
|
Create New Project
|
Ctrl+Shift+R
|
Open Resource (Java files,other
files,folder,projects)
|
Ctrl+W
|
Close Current Opened File.
|
Ctrl+Shift+W
|
Close All Files
|
F5
|
Refresh
|
Ctrl+C
|
Copy Some text or line.
|
Ctrl+V
|
Paste text or line.
|
Ctrl+X
|
Cut text or line
|
Ctrl+Z
|
Undo Last Action
|
Ctrl+Y
|
Redo Last Action
|
Ctrl+F
|
Open find and replace dialog to
find any word or strings of words.
|
Ctrl+H
|
Search Entire Workspace for
file,words etc
|
Ctrl+Shift+O
|
Organize all imports and remove
unnecessary imports
|
Ctrl+A
|
Select all text in class
|
Ctrl+I
|
Correct indention of selected
text or of current line or whole class
|
Ctrl+Shift+F
|
Format all code in class
|
Ctrl+/
|
Comment / un-comment line
|
Ctrl+Shift+/
|
Add Block Comment around
selection
|
Ctrl+Shift+\
|
Remove Block Comment
|
Ctrl+S
|
Save Current File.
|
Ctrl+Shift+S
|
Save All Files.
|
F11
|
Debug
|
F5
|
Step
Inside the function
|
F6
|
Next
step(line by line)
|
F7
|
Step
out of the function
|
F8
|
Skip
to next breakpoint
|