Organized collections of data organized so that items can be stored and retrieved by some fixed techniques
Code is translated into an intermediate form of code, byte code to make it easier to move programs between machines
Java Runtime Environmet
Controlls all Java programs and available on a wide variety of machines. this is why it is easy to move java programs between machines
- a procedure or sequence of directions for solving a problem
- part of the design phase of the program
- a single method can be used by many programs for similar tasks
- may be pre-written or you can write your own for specific use
- EX system.out.printf(...).
- Know something about what the other methods do. Only as much as you need to know but no more
- Write all methods seprately instead of trying to write whole program at once
- method name, parameter list, return type, any modifiers
- info on method
- EX: public static double celciusToFahrenheit(double c)
- public static - modifiers
- double - return type
- celciusToFahrenheit - method name
- double c - parameter list
- simplifies your reasoning by allowing you to consider methods one at a time rather than all together
- not look at how a method is implimented
- abstract away irrelevant details about how a method works
a condition that is supposed to be true when a method is called
a complete statement describing what will be true when the method finishes
- if procondition fails program may do strange things.
- Indicate that illegal argument has occured
- detect that precondition has been violated, halt its own work, pass a message, called an exception, to the calling program to indicate that an illegal argument has occured
Throwing an exception
the act of halting your own work and passing a message to the calling program
automatically produced by Javadoc, nicely formatted information about a class
Value will never be changed while the program is running
tells how subsequent arguments should be printed
part of the format string that begins with the % character. Indicates how the next item should be printed
- length of the number including the decimal point.
- EX %6.2f - field width = 6 _ _ _ . _ _
- number of decimal places.
- EX %6.2f - precision = 2 _ _ _ . _ _
Testing of boundary values
- boundary value is one step away from a different kind of behavior
- If you cannot test all possible values then test the boundary values, 0, 1, and -1.
- boolean expressions that can be checked for validity while the program is running
- assist in debugging and maintaining programs by documenting conditions that the programmer intends to be valid at specific locations in the program.
- automatically flag invalid assertions
- if assertion is true no action is taken, if false the exception called an assertion error is thrown
- "Each assertion contains a boolean expression that you believe will be true when the assertion executes. If it is not true, the system will throw an error. By verifying that the boolean expression is indeed true, the assertion confirms your assumptions about the behavior of your program"