All of these (and many many more) are available in the JDK you installed in Exercise 1.
java.lang
- language basics; no need to import explicitly
java.util
- common utility classes, useful data structures
java.io
- files, input/output
java.text
- text formatting (eg, for dates, numbers)
java.net
- network access: URLs, sockets, HTTP, etc
java.awt
& javax.swing
- graphics, GUI and events - all covered later
See the API documentation for details of each package. How to do this is coming next.
Later we will explain how to create your own packages and put classes in them.
On java.sun.com you can both access all of the documentation online and also download a copy to keep on your own hard disc. I like to have a downloaded copy but for now we will use the online one. Follow the steps below.
static int parseInt (String s)
, with a single sentence summarising what it does. (You can also see that there is another overloaded version of parseInt with a second parameter.) Often that is all you need to know but click on the name parseInt to see what happens.The really useful thing is that all Java APIs are documented in the same way, by using the javadoc utility program supplied in the JDK. Later in the course you will see how easy it is to generate similar documentation for your own code. I guarantee you will be wowed by that!
My own API documentation is available here: http://www.grelf.net/docs. Explore it and see how similar it is to Sun's documentation. You will soon be able to do this too.
1. What is strange about the month field of class Date?
2. Why do we need the class GregorianCalendar?
3. Which package is class ArrayList in, and why is it useful?
4. What is particularly useful (for commercial software) about BigDecimal?
5. Where is the value of pi?
6. What is class Long for?
7. Which classes have NaN fields, and what does NaN mean?
8. What is the maximum value a double variable can have?
9. How can you generate random numbers? Why might you?