Lecture Introduction to programming with Java - Chapter 11: Type details and alternate coding mechanisms

This chapter presents the following content: Primitive data types, integer types, floating-point types, char type, ASCII table, unicode standard, type conversions – promotions, type casting, prefix/postfix modes for increment/decrement operators, embedded assignment expressions, conditional operator expressions, expression evaluation practice, short-circuit evaluation, empty statement, break statement within a loop. | Chapter 11 – Type Details and Alternate Coding Mechanisms Primitive Data Types Integer Types Floating-Point Types char Type ASCII Table Unicode Standard Type Conversions – Promotions, Type Casting Prefix/Postfix Modes for Increment/Decrement Operators Embedded Assignment Expressions Conditional Operator Expressions Expression Evaluation Practice Short-Circuit Evaluation Empty Statement break Statement Within a Loop 1 Primitive Data Types In Java, there are two basic categories of values - primitive values and objects. For a while now, we've focused on objects. Now let's return to primitive values and cover them in more detail. Primitive values are categorized into these primitive data types: byte, short, int, long float, double char boolean 2 Integer Types To access a data type's minimum and maximum values, use the MIN_VALUE and MAX_VALUE named constants that come with the data type's wrapper class. For example, here's how to print the maximum int value: ("Largest int = " + ); Type Storage Wrapper Class's MIN_VALUE Wrapper Class's MAX_VALUE byte 8 bits -128 127 short 16 bits -32768 32767 int 32 bits -2 billion 2 billion long 64 bits -9*1018 9*1018 3 Integer Types Default integer constant type = int. To explicitly force an integer constant to be a long, use an l or L suffix. This generates a compilation error: long ageOfPlanet = 4540000000; But this, with the L suffix, works just fine: long ageOfPlanet = 4540000000L; 4 Floating-Point Types – float, double Normally, the double type is preferred over the float type because the double type provides more accuracy. For doubles, the number of significant digits is approximately 15. For floats, the number of significant digits is approximately 6. Type Storage Precision Wrapper Class's MIN_NORMAL Wrapper Class's MAX_VALUE float 32 bits 6 digits * 10-38 *1038 double 64 bits 15 digits * 10-308 *10308 5 Floating-Point Types – float, double To | Chapter 11 – Type Details and Alternate Coding Mechanisms Primitive Data Types Integer Types Floating-Point Types char Type ASCII Table Unicode Standard Type Conversions – Promotions, Type Casting Prefix/Postfix Modes for Increment/Decrement Operators Embedded Assignment Expressions Conditional Operator Expressions Expression Evaluation Practice Short-Circuit Evaluation Empty Statement break Statement Within a Loop 1 Primitive Data Types In Java, there are two basic categories of values - primitive values and objects. For a while now, we've focused on objects. Now let's return to primitive values and cover them in more detail. Primitive values are categorized into these primitive data types: byte, short, int, long float, double char boolean 2 Integer Types To access a data type's minimum and maximum values, use the MIN_VALUE and MAX_VALUE named constants that come with the data type's wrapper class. For example, here's how to print the maximum int value: .

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.