Back to category: Technology

Limited version - please login or register to view the entire paper.

My Own Java Note

Date: 9-11-03
I. Interface
-Collection of constants & abstract methods(no code)
-An interface can not be instantiated
-The header method, including parameter list, is followed by a semi-colon

public interface Complex
{
public void setComplexity(int num)
public int getComplexity();
}

To implement:
Public class CLASS_NAME implements Complex
{
public void setComplexity(int value)
{
code
}
}
Examples:
public interface Fillable
{
public void fill(int x);
public int getCurrentAmount();
public int getMaxCapacity();
}

public class Car implements Fillable
{
public void fill(int gallons)
{
fuelAmount+=gallons;
}
public int getCurrentAmount
{
return fuelAmount;
}
public int getMaxCapacity
{
return capacity
}
}

public class VendingMachine implements Fillable
{
public void fill(int qty)
{
currentStock+=qty;
...

Posted by: Justin Rech

Limited version - please login or register to view the entire paper.