Primitive data types and expressions A data type is a set of values and a set of
operations on those values. We begin by considering the following four primitive data
types that are the basis of the Java language:
■ Integers, with arithmetic operations (int)
■ Real numbers, again with arithmetic operations (double)
■ Booleans, the set of values { true, false } with logical operations (boolean)
■
Characters, the alphanumeric characters and symbols that you type (char)
Next we consider mechanisms for specifying values and operations for these types.
A Java program manipulates variables that are named with identifiers. Each variable
is associated with a data type and stores one of the permissible data-type values. In Java
code, we use expressions like familiar mathematical expressions to apply the operations
associated with each type. For primitive types, we use identifiers to refer to variables,
operator symbols such as + - * / to specify operations, literals such as 1 or 3.14 to
specify values, and expressions such as (x + 2.236)/2 to specify operations on values.
The purpose of an expression is to define one of the data-type values.
Primitive data types and expressions A data type is a set of values and a set ofoperations on those values. We begin by considering the following four primitive datatypes that are the basis of the Java language:■ Integers, with arithmetic operations (int)■ Real numbers, again with arithmetic operations (double)■ Booleans, the set of values { true, false } with logical operations (boolean)■Characters, the alphanumeric characters and symbols that you type (char)Next we consider mechanisms for specifying values and operations for these types.A Java program manipulates variables that are named with identifiers. Each variableis associated with a data type and stores one of the permissible data-type values. In Javacode, we use expressions like familiar mathematical expressions to apply the operationsassociated with each type. For primitive types, we use identifiers to refer to variables,operator symbols such as + - * / to specify operations, literals such as 1 or 3.14 tospecify values, and expressions such as (x + 2.236)/2 to specify operations on values.The purpose of an expression is to define one of the data-type values.
การแปล กรุณารอสักครู่..