Chapter-6 Data Types
Chapter-6 Data Types
Data Types
ISBN 0-321-33025-0
Primitive Data Types
• Almost all programming languages provide a set of
primitive data types
• Primitive data types: Those not defined in terms of
other data types
• Java
– Primitive via the String class
Compile-time Run-time
descriptor for descriptor for
static strings limited dynamic
strings
• Ada’s design
type Days is (mon, tue, wed, thu, fri, sat, sun);
subtype Weekdays is Days range mon..fri;
subtype Index is Integer range 1..100;
Day1: Days;
Day2: Weekday;
• Reliability
– Assigning a value to a subrange variable that is outside the
specified range is detected as an error
• Index Syntax
– FORTRAN, PL/I, Ada use parentheses
– Most other languages use brackets