Defining a Constructor In an Interface Java? I have multiple different implementations of an object, which implement this custom interface I made called Board.

Board contains a method that looks like the following

public void ConvertFromString(String formattedString);


Each object implementing Board calls ConvertFromString() in its constructor. 

Looks like the following.

public void BoardImpl1 implements Board
{
    public Board(string B)
    {
        ConvertFromString(b);
    }

    public void ConvertFromString(String formattedString)
    {
        //do some parsing on string and set up the BoardImpl properties
    }
}


ConvertFromString being public causes a warning, so the best practice workaround would be to make BoardImpl final. Is there a better way to write this?
The warning you get, is because you call an overridable method from your constructor. This is bad because subclasses may change the implementation of the method to access other parts of the object, while it is not fully initialized yet.

So to get rid of the warning : don't call overridable methods from the constructor.

Then how to get around your predicament?

Well you could : 


make the public method final.
make the class final (which you found yourself)
duplicate the logic (while possible, not the way to go)
have the public method delegate to a private method, and have the constructor call the private method.


Like this : 

public class BoardImpl implements Board {
    public BoardImpl(String b) {
        doConvertFromString(b);
    }

    public void convertFromString(String formattedString) {
        doConvertFromString(formattedString);
    }

    private void doConvertFromString(String formattedString) {
        //do some parsing on string and set up the BoardImpl properties
    }
}


I wouldn't worry about making all implementations final. final is your friend.