Exercise 3-12 (HelloDate with Javadoc)
Chapter_3 Exercise_3-11 | Exercises_3-13,14 |
Exercise 3-12 TIJ, p. 61
Exercise 3-12: (2) Find the code for the second version of HelloDate.java, which is the simple comment documentation example. Execute Javadoc on the file and view the results with your Web browser.
HelloDate.java TIJ, p. 59
// HelloDate.java
import java.util.Date;
/**
* The first Thinking in Java example program.
* Displays a string and today’s date.
* @author Bruce Eckel
* @author www.MindView.net
* @version 4.0
*/
public class HelloDate
{
/**
* Entry point to class and application.
* @param args array of {@link java.lang.String String} arguments
* @throws exceptions No exceptions thrown
*/
public static void main(String[] args)
{
System.out.print("Hello, it’s: "); // no newline
System.out.println(new Date());
// System.out.println(new Date().toString());
}
}
/*
javac HelloDate.java
java HelloDate
Hello, it’s: Thu Jul 13 14:24:22 EEST 2023
javadoc HelloDate.java -d doc -author -version
javadoc HelloDate.java -d doc -author -version \
-link https://docs.oracle.com/en/java/javase/21/docs/api/
*/
Notes:
-d doc // specify destination directory for javadoc output; if doc does not exist, it is created;
-author -version // include information about authors and version in the output;
-link https://docs.oracle.com/en/java/javase/21/docs/api/ // link online Java API.
\ at the end of a line allows a command to continue on the next line.
Chapter_3 Exercise_3-11 | BACK_TO_TOP | Exercises_3-13,14 |
Comments
Post a Comment