-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathimportant_topics.txt
37 lines (28 loc) · 1016 Bytes
/
important_topics.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
***Double Precision***
If you want to have the result in a String instead of being printed to the console, use String.format() with the same arguments:
String result = String.format("%.2f", value);
Or use class DecimalFormat:
DecimalFormat df = new DecimalFormat("####0.00");
System.out.println("Value: " + df.format(value));
***BigInteger***
static BigInteger factorial(int N)
{
// Initialize result
BigInteger f = new BigInteger("1"); // Or BigInteger.ONE
// Multiply f with 2, 3, ...N
for (int i = 2; i <= N; i++)
f = f.multiply(BigInteger.valueOf(i));
return f;
}
Comparing a doulbe with int is valid in java
**HashSet**
1. no duplicates allowed
2. does not maintain insertion order
3. null values are allowed
HashSet h = new HashSet();
h.contains(valueToBeChecked) // return true if contains else false
h.add(valueToBeAdded); // add value
Iterator val = h.iterator();
while(val.hasNext() ) {
sout(val.next() ); // display value
}