93 terms

Java Class Library

STUDY
PLAY
public ArrayList ( )
Creates an empty list.
public void add(int index, Object element)
Insert the element into this list at the index.
public boolean add(Object obj)
Appends the element to the end of the list.
public Object get(int index0
Returns the element at the index. Throws IndexOutOfBoundsException if the index is out of range.
public Iterator iterator ( )
Returns an Iterator containing the elements in this list.
public ListIterator listIterator ( )
Returns a ListIterator containing the elements in this list.
public Object remove(int index)
Removes and returns the object at the index in this list. Throws IndexOutOfBoundsException if the index is out of range.
public Object set(int index, Object obj)
Replaces the element at the index with the object.
public int size ( ) - ArrayList
Returns the number of elements in this list.
public int compareTo (Object other)
Compares this object to other. If they are equal, returns zero. If this object is less than other, returns an int less than zero. If this object is greater than other, returns into greater than zero.
public Double(double arg)
Creates an instance of the Double class from the parameter arg.
public double doubleValue ( )
Returns the value of the current object as double.
public int compareTo ( ) (Object param)
Compares this Double to param. Returns zero if they are equal, less than zero if this Double is less than param, or greater than zero if this Double is greater than param.
public boolean equals(Object param)
Returns a true value if this Double is equal to the specified parameter (param).
public String to String ( )
Returns the string representation of the current object.
public HashMap ( )
Creates an empty map.
public boolean containsKey (Object Key)
Returns true if this map contains the key.
public Object get (Object key)
Returns the value to which the key maps, or null if this map does not contain the key.
public Set keySet ( )
Returns a Set containing the keys in this map.
public Object put (Object key, Object value)
Adds the key-value pair to this map. The value previously associated with the key is returned, or null if there was previously no mapping for the key.
public int size ( ) - Hash Maps
Returns the number of key-value pairs in this map.
public HashSet ( )
Creates an empty set.
public boolean add (Object obj)
Adds the element to this set if it is not already present. Returns true if the element was added to the set, false if it was already there.
public boolean contains (Object obj)
Returns true if this set contains the specified element.
public Iterator iterator ( ) - HashSet
Returns an iterator over the elements in this set.
public boolean remove (Object obj)
Removes the specified element from this set if it is present. Returns true if this set contained the specified element, false otherwise.
public int size ( )
Returns the number of elements in this set.
public Integer(int num)
Creates an instance of the Integer class from the parameter num.
public int compareTo (Object num)
Compares this integer to num. Returns zero if they are equal, less than zero if this integer is less than num, or greater than zero if this integer is greater than num.
public int intValue ( )
Returns the value of this integer as an int.
public boolean equals (Object num)
Returns the result of an equality comparison against num.
public String toString ( )
Returns the string representation of this integer.
public boolean hasNext ( )
Returns true if the executing object contains one or more objects that have not been returned by the next method.
public Object next ( )
Returns a reference to the next object in the iterator.
public void remove ( )
Removes the item most recently returned by the next method from the collection.
public LinkedList ( )
Creates an empty list.
public Iterator iterator ( ) - LinkedList
Returns an iterator of the elements in the list.
public ListIterator iterator ( )
Returns a ListIterator of the elements in this list.
public int size ( ) - LinkedList
Returns the number of elements in this list.
public void add (Object obj)
Adds the element to the end of this list.
public void addFirst (Object obj)
Adds the element to the beginning of this list.
public void AddLast (Object obj)
Adds the element to the end of this list.
public Object getFirst ( )
Returns the first element in this list.
public Object getLast ( )
Returns the last element in this list.
public Object removeFirst ( )
Removes and returns the first element from this list.
public Object removeLast ( )
Removes and returns the last element of this list.
public boolean add (Object obj) - List
Adds an element to the end of the list.
public int size ( ) - List
Returns the number of elements in the list.
public Iterator iterator ( ) - List
Returns an iterator of the elements in this list.
public ListIterator listIterator ( ) - List
Returns a ListIterator of the elements in the list.
Development activities
These are establishing the requirements, creating a design, implementing the code, and testing the implementation
Software Requirements
Specify what a program must accomplish
Client
The person or group who wants a software product developed and they usually give a set of requirements
Software Design
Spells out how a program will accomplish its requirements
Algorithm
Step-by-step process for solving a problem, often expressed in psudeocode
Psuedocode
A mixture of code statements and english phrases, sort of like the rough draft
Implementation
The process of writing the source code in a prticular programming language
Top-down Developement
During implementation start at top level and work down to smaller more detailed peices
Testing
Running a program many times and carefully studying the results
Regression Testing
When one program is fixed, run it again to see if any other errors were created
Flow of Control
The order in which statements are executed
Conditional Statement
Lets you choose which statement will be executed next
Boolean Expression
Says whether something will be true or false
Loop / Repitition Statement
Lets you execute the same statement over and over again
If Statement
Statement that runs if it is true, otherwise it skips over
Equality Operators
==' or '!=' (equal to / not equal to)
Relational Operators
<' '<=" '>' ">=' (less than / less than or equal to / greater than / greater than or equal to)
If / Else Statement
Adds else clause to if statement which allows something else to be ran if first part is fasle
Block Statement
A collection of statements enclosed in braces
Nested if
The statement executed as the result of an if statement could be another if statement
Logical Operators
"!" "&&" "||"
Logical Compliment
The ! is used to perform the logical NOT operation
Truth Table
A table that lists all the combinations of values for the variables involved in an expression
Lexicorgraphic Ordering
Comparing characters and strings is based on unicode character set
Increment Operator
(++) adds 1 to any integer or floating point value
Incremented
(--) deducts 1 from any integer or floating point value
Assignment Operators
Combine basic operation with assignment ie. (=, +=, -=, *=, /=, %=)
While Statement
A loop that evaluates a boolean condition - just like an if statement- and executes a statement if the condition is true
Sentinal Value
A value that shows the end of input
Running Sum
The total of values entered so far
Validate the Input
We guarantee that the user enters a value that we consider to be valid
Robust
Handles errors well, even user errors
Infinate Loop
When a statement repeats nonstop until a user breaks it
Nested Loop
When the body of a loop also contains a loop
Palindrome
A string of characters that is the same when read forwards and backwards (ex. "madam")
Iterator
An object that has methods that allow you to process a collection of items at once
For Statement
A statement similar to a while statement, but this is serves better when you know exactly how many time you want something to repeat
Initialization
The first part of the 'for statement' header
Increment
Third part of the 'for statement' header
Foreach Statment
Process each object in the iterator in turn
Logical NOT (!)
(! a) True if a is false and false ifa is true
Logical AND (&&)
The result is true if both operands are true, but false otherwise
Logical OR (||)
The result is true if either operands are true
YOU MIGHT ALSO LIKE...