Java Reference
In-Depth Information
Data Types
Data types in can be divided into two categories: Primitive types and Object types.
Primitive types include the following five data types:
Undefined
Null
Number
Boolean
String
The Undefined Type
The Undefined type has only one value that is called undefined . A variable in Nashorn
that is declared but is assigned a value has the value undefined . You can also assign the
value undefined to a variable explicitly. In addition, you can compare another value with
undefined . The following snippet of code shows how to use the value undefined :
// empId is initialized to undefined implicitly
var empId;
// deptId is initilaized to undefined explicitly
var deptId = undefined;
// Print the values of empId and deptId
print("empId is", empId)
print("deptId is", deptId);
if (empId == undefined) {
print("empId is undefined")
}
if (deptId == undefined) {
print("deptId is undefined")
}
empId is undefined
deptId is undefined
empId is undefined
deptId is undefined
 
Search WWH ::




Custom Search