Send the link below via email or IMCopy
Present to your audienceStart remote presentation
- Invited audience members will follow you as you navigate and present
- People invited to a presentation do not need a Prezi account
- This link expires 10 minutes after you close the presentation
- A maximum of 30 users can follow your presentation
- Learn more about this feature in our knowledge base article
Do you really want to delete this prezi?
Neither you, nor the coeditors you shared it with will be able to recover it again.
Make your likes visible on Facebook?
You can change this under Settings & Account at any time.
Java Classes and Objects
Transcript of Java Classes and Objects
format method The Product Java Scanner Class String Class pseudorandom number generator
import declaration: import java.util.Random; Random Class standard class
standard class Math Class Classes & Objects instantiated in the usual way using the new operation
its constructor takes a string that represents the formatting pattern, which can then use the format method to format a particular value DecimalFormat Class By: Shridha A. & Priscilla P. Class Class Library set of classes that supports the development program w/ a compiler
classes from the java.lang package is used when writing a program
Other classes from other packages can be used if full quality referenced or imported through a declaration
import declaration identifies packages and class so that a fully qualified name is not necessary with each reference. ex. import java.util.Random; not part of Java language
part of the Java standard class library Examples of Random method:
is a constructor that creates a new pseudorandom number generator.
double nextDouble ()
returns a random number between 0.0(inclusive)and 1.0(exclusive).
int nextInt (int num)
returns a randiom number in the range 0 to num- Examples of methods in Math Class: static int abs (int num)
static double abs (double num)
returns the absolute value of num.
static double exp (double power)
returns the value e raised to the specific power.
static double sqrt (double num)
returns the square root of num, which must be positive. standard Java class
allows values of various types to be inputted declaration creates a Scanner object:
Scanner scan = new Scanner (System.in); Examples of methods in the NumberFormat class:
String format (double number)
returns a string containing the specific number formatted according to this object’s pattern.
static NumberFormart getCurrencyInstance()
returns a NumberFormat object that represents a currency format for the current locale
static NumberFormat getPercentInstance()
returns a NumberFormat object that represents a percentage format for the current locale. Examples of methods in the DecimalFormat class:
DecimalFormat (String pattern)
Constructor: creates a new DecimalFormal object with a specified pattern,
void applyPattern (String pattern)
Applies the specific pattern to this DecimalFormat object.
String format (double number)
Returns a string containing the specified number formatted according to the current pattern. Program Development steps 1) establishing the requirements
2) creating a design
3) implementing the code
4) testing the implementation NumberFormat class formats numbers
format method Flow of Control Order of statements in a program that are executed THE END:) task that a program must do Software Requirements Software Designs describe how the program requirements are met
how the classes and objects of the program work together
basic design is an algorithm Implementation
writing of the program
top-down development Testing
run the program many times to review results