Thursday, 12 March 2009

Java™ How to Program, Sixth Edition - Part28

Few weeks back i started reading Java™ How to Program, Sixth Edition By H. M. Deitel - Deitel & Associates, Inc., P. J. Deitel - Deitel & Associates, Inc.

Nice book written By H. M. Deitel - Deitel & Associates, Inc., P. J. Deitel - Deitel & Associates, Inc.

I wanted to share few quotations found the book from the 28th chapter.

1) Input and output are usually performed with streams, which are sequences of bytes. In input operations, the bytes flow from a device to main memory. In output operations, bytes flow from main memory to a device.

2) Normally, the standard input stream is connected to the keyboard, and the standard output stream is connected to the computer screen.

3) The printf format string describes the formats in which the output values appear. The format specifier consists of argument index, flags, field widths, precisions and conversion characters.

4) Integers are printed with the conversion characters d for decimal integers, o for integers in octal form and x (or X) for integers in hexadecimal form. When the conversion character X is used, the output is displayed in uppercase letters.

5) Floating-point values are printed with the conversion characters e (or E) for exponential notation, f for regular floating-point notation, and g (or G) for either e (or E) notation or f notation. When the g conversion specifier is indicated, the e conversion character is used if the value is less than 103 or greater than or equal to 107; otherwise, the f conversion character is used. When the conversion characters E and G are used, the output is displayed in uppercase letters.

6) The conversion character c prints a character.

7) The conversion character s (or S) prints a string of characters. When the conversion character S is used, the output is displayed in uppercase letters.

8) The conversion character t (or T) followed by a conversion suffix character prints the date and time in various forms. When the conversion character T is used, the output is displayed in uppercase letters.

9) Conversion character t (or T) requires the argument to be of type long, Long, Calendar or Date.

10) Conversion character b (or B) outputs the string representation of a boolean or Boolean. These conversion characters also output "true" for non-null references and "false" for null references. When conversion character B is used, the output is displayed in uppercase letters.

11) Conversion character h (or H) returns null for a null reference and a String representation of the hash code value (in base 16) of the object. Hash codes are used to store and retrieve objects in Hashtables and HashMaps. When conversion character H is used, the output is displayed in uppercase letters.

12) The conversion character n prints the platform-specific line separator.

13) The conversion character % is used to display a literal %.

14) If the field width is larger than the object being printed, the object is right justified in the field by default.

15) Field widths can be used with all conversion characters except the line-separator conversion.

16) Precision used with floating-point conversion characters e and f indicates the number of digits that appear after the decimal point. Precision used with floating-point conversion character g indicates the number of significant digits to appear.

17) Precision used with conversion character s indicates the number of characters to be printed.

18) The field width and the precision can be combined by placing the field width, followed by a decimal point, followed by the precision between the percent sign and the conversion character.

19) The - flag left justifies its argument in a field.

20) The + flag prints a plus sign for positive values and a minus sign for negative values.

21 The space flag prints a space preceding a positive value. The space flag and the + flag cannot be used together in an integral conversion character.

22) The # flag prefixes 0 to octal values and 0x to hexadecimal values.

23) The 0 flag prints leading zeros for a value that does not occupy its entire field.

24) The comma (,) flag uses the locale-specific thousands separator (i.e., ',' for U.S. locale) to display integer and floating-point numbers.

25) The ( flag encloses a negative number in parentheses.

26) An argument index is an optional decimal integer followed by a $ sign that indicates the position of the argument in the argument list.

27) Argument indices enable programmers to reorder the output so that the arguments in the argument list are not necessarily in the order of their corresponding format specifiers. Argument indices also help avoid duplicating arguments.

28) Class Formatter (in package java.util) provides the same formatting capabilities as printf. Formatter is a utility class that enables programmers to print formatted output to various destinations, including GUI components, files and other output streams.

29) Class Formatter's method format outputs formatted data to the destination specified by the Formatter constructor.

30) The static method format of class String formats data and returns the formatted data as a String.

About the Authors

Dr. Harvey M. Deitel, Chairman and Chief Strategy Officer of Deitel & Associates, Inc., has 43 years experience in the computing field, including extensive industry and academic experience. Dr. Deitel earned B.S. and M.S. degrees from the Massachusetts Institute of Technology and a Ph.D. from Boston University. He worked on the pioneering virtual-memory operating-systems projects at IBM and MIT that developed techniques now widely implemented in systems such as UNIX, Linux and Windows XP. He has 20 years of college teaching experience, including earning tenure and serving as the Chairman of the Computer Science Department at Boston College before founding Deitel & Associates, Inc., with his son, Paul J. Deitel. He and Paul are the co-authors of several dozen books and multimedia packages and they are writing many more. With translations published in Japanese, German, Russian, Spanish, Traditional Chinese, Simplified Chinese, Korean, French, Polish, Italian, Portuguese, Greek, Urdu and Turkish, the Deitels' texts have earned international recognition. Dr. Deitel has delivered hundreds of professional seminars to major corporations, academic institutions, government organizations and the military.

Paul J. Deitel, CEO and Chief Technical Officer of Deitel & Associates, Inc., is a graduate of the MIT's Sloan School of Management, where he studied Information Technology. Through Deitel & Associates, Inc., he has delivered Java, C, C++, Internet and World Wide Web courses to industry clients, including IBM, Sun Microsystems, Dell, Lucent Technologies, Fidelity, NASA at the Kennedy Space Center, the National Severe Storm Laboratory, Compaq, White Sands Missile Range, Rogue Wave Software, Boeing, Stratus, Cambridge Technology Partners, Open Environment Corporation, One Wave, Hyperion Software, Adra Systems, Entergy, CableData Systems and many other organizations. Paul is one of the most experienced Java corporate trainers having taught about 100 professional Java training courses. He has also lectured on C++ and Java for the Boston Chapter of the Association for Computing Machinery. He and his father, Dr. Harvey M. Deitel, are the world's best-selling Computer Science textbook authors.

No comments: