Class
Classes are the template through which objects are created. It is the formal blueprint for creating objects.
Object
An object is a variable of a data type that is user defined. Every object has a state and a behavior.
Instance
A created object with defined attributes.
State
The data that is associated with an object or class.
Behavior
The actions that can be completed by an object or class.
Object Oriented Programming
The use of object and class types in programming.
String
input.nextLine()
int
input.nextInt()
double
input.nextDouble()
Method
Procedures that allow us to control and define the behavior of an object.
Access Specifier
Determines who has access to using the method when writing classes and objects.
Return Type
Indicates what type value is being returned from the method.
Calling a Method
objectName.method()
Procedural Abstraction
The ability to use methods and programs that we do not fully understand, or are unable to write.
Method overloading
Methods can have multiple signatures. Java will use the correct signature based on the actual parameters used in a program.
return keyboard
Used to return a value back to the main program from a method.
Scope
Defines which part of the program a variable can be accessed from.
String(String str) constructor
Constructs a new String object that represents the same sequence of characters as str
int length()
Returns the number of characters in a String object
String substring(int from, int to)
Returns the substring beginning at index from and ending at index to − 1
String substring(int from)
Returns substring(from, length())
IndexOutOfBoundsException
A String object has index values from 0 to length – 1. Attempting to access indices outside this range will result in this error.
int indexOf(String str)
Returns the index of the first occurrence of str; returns -1 if not found.
int compareTo(String other)
Returns a value < 0 if this is less than other; returns zero if this is equal to other; returns a value > 0 if this is greater than other.
Application Programming Interfaces
APIs and libraries simplify complex programming tasks by providing sets of clearly defined methods of communication among various computing components.
Documentation
Documentation is the reference for how to use different methods and classes.
Integer(int value) and Double(double value)
Constructs a new Integer object or a new Double Object that represents the specified int or double value.
Integer and Double Classes
These classes are part of the java.lang package and Object class and have a number of useful methods.
Integer.MIN_VALUE and Integer.MAX_VALUE
The minimum/maximum value represented by an int or Integer, which are -2147483648 and 2147483647.
int intValue() and double doubleValue()
Returns the value of this Integer as an int and this Double as a double.
Autoboxing
Automatic conversion between primitive types and their corresponding object wrapper classes.
Unboxing
Reverse of autoboxing; automatic conversion from the wrapper class to the primitive type.
Static Methods
Static methods are the methods in Java that can be called without creating an object of class. Static methods are called using the dot operator along with the class name unless they are defined in the enclosing class.
Math Class
The Math class is part of the java.lang package and contains only static methods.
int abs(int x)
Returns the absolute value of an int value.
double abs(double x)
Returns the absolute value of a double value.
double pow(double base, double exponent)
Returns the value of the first parameter raised to the power of the second parameter.
double sqrt(double x)
Returns the positive square root of a double value.
double random()
Returns a double value greater than or equal to 0.0 and less than 1.0.
Math.random
Can be manipulated to produce a random int or double in a defined range.