The following table shows the COBOL data type that corresponds to each Java
primitive type.
Table 14. Comparison of COBOL and Java Data Types
Java Primitive Type | Description | Java Data Range | COBOL Data Type | COBOL Data Range |
---|---|---|---|---|
boolean | unsigned 8 bits | 0 (false) or 1 (true) | PIC 9(4) BINARY | 0 to 255 |
byte | signed 8 bits | -128 to 127 | PIC X | -128 to 127 |
char | unsigned 16 bits | 0 ('\u0000') to 65535 ('\uffff') | PIC N USAGE NATIONAL | 0 ('\u0000') to 65535 ('\uffff') |
short | signed 16 bits | -32768 to 32767 | PIC S9(4) BINARY 1 | -32768 to 32767 |
int | signed 32 bits | -2147483648 to 2147483647 | PIC S9(9) BINARY 1 | -2147483648 to 2147483647 |
long | signed 64 bits | -9223372036854775808 to 9223372036854775807 | PIC S9(18) BINARY 1 | -9223372036854775808 to 9223372036854775807 |
float | 32 bits | 1.40239846e-45f to 3.40282347e+38f | USAGE COMP-1 | 0.14012985e-44 to 0.34028235e39 |
double | 64 bits | 4.94065645841246544e-324 to 1.79769313486231570e+308 | USAGE COMP-2 | .11125369292536009e-307 to .17976931348623155e+309 |
void | n/a | n/a | n/a | n/a |
Notes:
|
The COBOL and Java data ranges are similar.
A Java reference type consists of a class, an interface and an array. A reference type is passed as a Java int type argument.
Figure 66. Defining Java Data Types
01 JBOOLEAN TYPEDEF PIC 9(4) BINARY. 01 JBYTE TYPEDEF PIC X. 01 JCHAR TYPEDEF PIC N USAGE NATIONAL. 01 JSHORT TYPEDEF PIC S9(4) BINARY. (and NOSTDTRUNC on PROCESS statement) 01 JINT TYPEDEF PIC S9(9) BINARY. (and NOSTDTRUNC on PROCESS statement) 01 JLONG TYPEDEF PIC S9(18) BINARY. (and NOSTDTRUNC on PROCESS statement) 01 JFLOAT TYPEDEF USAGE COMP-1. 01 JDOUBLE TYPEDEF USAGE COMP-2. |
(C) Copyright IBM Corporation 1992, 2005. All Rights Reserved.