Java Reference
In-Depth Information
method to copy the contents of a
grades
array to a
gradesBackup
array.
Tip
The
arraycopy()
method is the fastest portable way to copy one array to
another.Also,whenyouwriteaclasswhosemethodsreturnareferencetoaninternal
array,youshoulduse
arraycopy()
tocreateacopyofthearray,andthenreturnthe
copy's reference. That way, you prevent clients from directly manipulating (and pos-
sibly screwing up) the internal array.
main()
next calls
currentTimeMillis()
to return the current time as a mil-
liseconds value. Because this value is not human-readable, you might want to use the
java.util.Date
class (discussed in Appendix C). The
Date()
constructor calls
currentTimeMillis()
and its
toString()
method converts this value to a
readable date and time.
main()
concludesbydemonstrating
getProperty()
inaforloop.Thisloopit-
erates over all of
Table 4-6
's property names, outputting each name and value.
When I run this application on my platform, it generates the following output:
86
92
78
65
52
43
72
98
81
Current time: 1312236551718
java.vendor.url: http://java.oracle.com/
java.class.path: .
user.home: C:\Documents and Settings\Jeff Friesen
java.class.version: 51.0
os.version: 5.1
java.vendor: Oracle Corporation
user.dir: C:\prj\dev\bj7\ch04\code\SystemTasks
user.timezone:
path.separator: ;
os.name: Windows XP