some standard classes
play

Some Standard Classes Chapter 13 1 For Next Time Read Chapter 13 - PowerPoint PPT Presentation

Some Standard Classes Chapter 13 1 For Next Time Read Chapter 13 2 Packages Classes can be organized into packages The core classes reside in the java.lang package No import is needed Classes include System , String , Math ,


  1. Some Standard Classes Chapter 13 1

  2. For Next Time  Read Chapter 13 2

  3. Packages  Classes can be organized into packages  The core classes reside in the java.lang package  No import is needed  Classes include System , String , Math , and the primitive type wrapper classes  java.util is another useful package 3

  4. System class  The public out constant object provides the printing methods print() , println() , and printf()  currentTimeMillis() returns the system time as milliseconds since midnight, January 1, 1970  The exit() method terminates a running Java program 4

  5. String class 5

  6. Wrapper classes 6

  7. Useful wrapper methods 7

  8. DecimalFormat class  An alternative to System.out.printf()  Allows numbers to be formatted as strings  Define a format template string  # a number placeholder; number appears if necesssary  0 a number placeholder; zero always appears  Create a DecimalFormat object from the format template string  Use the format() method to create a string 8

  9. Math class 9

  10. A Math -worthy problem 10

  11. Random class  Use to create pseudorandom number generator objects  Good enough for most purposes  Useful in games, simulations, and testing  nextInt() method returns a pseudorandom integer  If r is a Random object,  r.nextInt( n ) returns a psuedorandom integer from the range 0 … n – 1 11

  12. Next . . . The object class . . . 12

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend