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

some standard classes
SMART_READER_LITE
LIVE PREVIEW

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 ,


slide-1
SLIDE 1

1

Some Standard Classes

Chapter 13

slide-2
SLIDE 2

2

For Next Time

 Read Chapter 13

slide-3
SLIDE 3

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

slide-4
SLIDE 4

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

slide-5
SLIDE 5

5

String class

slide-6
SLIDE 6

6

Wrapper classes

slide-7
SLIDE 7

7

Useful wrapper methods

slide-8
SLIDE 8

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

slide-9
SLIDE 9

9

Math class

slide-10
SLIDE 10

10

A Math-worthy problem

slide-11
SLIDE 11

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

slide-12
SLIDE 12

12

Next . . .

The object class . . .