Java Reference
In-Depth Information
Type
Description
No.
Range Equivalent
COBOL
of Bits
PIC X(nnn) 1
String
Sequence of
16 (each)
Any set of Unicode
characters
characters
Array
Group of
N/A
Any object or data
OCCURS
variables
type variable(s)
PIC S9(n) COMP-3 2
BigDecimal
Fixed precision
Variable
Unlimited
number
PIC S9(n) COMP-3 2
BigInteger
Fixed precision
Variable
Unlimited
integer
Object
Object reference
An object reference
01 CTL-AREA
variable
variable for any class type
1. COBOL strings are always fixed-length 8-bit characters and bank padded to the defined size of the item. Java
strings are variable-length Unicode characters and have an embedded size attribute. I will discuss strings later.
2. Sometimes just COMP, COBOL's packed decimal type.
Values can easily be converted between the various data types, but in many
cases, you have to be explicit. A type cast is used to indicate to the compiler that you
intend to convert from one type to another; otherwise, the compiler might think
you are making a mistake!
int counter = 23;
// 'F' indicates a float constant
float bigNumber = 1.23F; // or 1.23f;
double biggerNumber = 123.45;
// Direct assignment from integer to floating point data types is possible.
bigNumber = counter;
// Direct assignment from floating point to integer data types is not
// possible.
counter = bigNumber;
// this is a compile error
// Move the floating point number to the integer, using a cast. Of course,
// some precision may be lost, but you've told the compiler you know what
// you're doing.
counter = (int) bigNumber;
 
Search WWH ::




Custom Search