|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object ch.arrenbrecht.jcite.examples.Adder
public class Adder
Class that adds a specific value to other values. Typical usage:
Adder ten = new Adder( 10 ); int result = ten.addTo( 5 );Note how we can omit the package specification of the target class if it resides in the same package as this class. If the class is in another package, we have to specify it:
System.out.println( "This code is in a different package." );
Constructor Summary | |
---|---|
Adder(int addThis)
Creates a new adder. |
Method Summary | |
---|---|
static int |
add(int a,
int b)
Adds two numbers. |
int |
addTo(int x)
Adds the number with which this Adder was constructed to the argument. |
int |
getAddend()
Returns the addend which was passed to the constructor. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Adder(int addThis)
addThis
- the number added by addTo(int)
.Method Detail |
---|
public int addTo(int x)
Adder ten = new Adder( 10 ); int result = ten.addTo( 5 );
x
- the number to add this Adder's number to.
public static int add(int a, int b)
int sum = Adder.add( 1, 2 );Note how, in the parameter documentation, we can cite from the current class's source directly, that is, omitting the target class part.
a
- first addend, as in return a + b;
b
- second addend, as in return a + b;
public int getAddend()
Adder one = new Adder( 1 ); int addend = one.getAddend(); assertEquals( 1, addend );
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |