-3

Just when you think you've seen it all, the code below pops up in a java .class I'm hoping to learn from.

I'm not entirely sure what is happening here. First clean(); is declared but looks like both a field and a method at the same time?

Then another method below it uses this clean(); despite there not being any code inside backets after its declaration?

I'm very confused. Could anyone shed some light on this syntax?

public abstract void clean();

/**
 * Clean method called whenever the user interface is closed, in order to clean
 * internal and user-defined structures properly.
 */
void cleanFromUI()
{
    // clean user-specific items
    try
    {
        clean();
    }
    catch (EzException eze)
    {
        // do not display anything as the interface is being closed
        if (!eze.catchException) throw eze;
    }

    // clear all variables

    ezVars.clear();

    ezgui = null;

    synchronized (nbInstances)
    {
        nbInstances.setValue(nbInstances.getValue() - 1);
    }
}
Zyzyx
  • 492
  • 4
  • 18
  • Possible duplicate of [Abstract methods in Java](https://stackoverflow.com/questions/6020649/abstract-methods-in-java#6020664) – LuCio Jul 04 '18 at 10:31

1 Answers1

0

In your code I observed 1 abstract method . Therefore class will be abstract. Abstract class can never be instantiated. If you want to user it's members you have to extend this class and provide implementation for that abstract method .then you can call the method which in turn calling clean() method.

Note:Abstract class provides partial implementation and set standard for subclasses to provide implementation and complete it.

spa
  • 329
  • 1
  • 3
  • 15