Java Reference
In-Depth Information
Character
Description
0
Digit; zero if no digit is present
Decimal
.
Minus or negative sign
-
,
Comma or grouping separator
Scientific notation separator
E
Positive and negative subpattern separator
;
The DecimalFormat class provides enough flexibility to format double and
long values for just about every situation.
4-3. Comparing int Values
Problem
You need to compare two or more int values.
Solution #1
Use the comparison operators to compare integer values against one another. In the fol-
lowing example, three int values are compared against each other, demonstrating
various comparison operators:
int int1 = 1;
int int2 = 10;
int int3 = -5;
System.out.println(int1 == int2);
// Result: false
System.out.println(int3 == int1);
// Result: false
System.out.println(int1 == int1);
// Result: true
System.out.println(int1 > int3);
// Result: true
System.out.println(int2 < int3);
// Result: false
As you can see, comparison operators will generate a Boolean result.
Search WWH ::




Custom Search