How to avoid code repetition initializing final properties?
- by Hernán Eche
public class Code{
//many properties
//...
final String NEWLINE;// ohh a final property!
void creation() //this method is for avoid repetition of code
{
//final initialization can't be put here =(
Source= new StringBuffer();
//many other commons new's ..
//...
}
Code()
{
NEWLINE = System.getProperty("line.separator");
creation();
}
Code(String name, int numberr)
{
NEWLINE = System.getProperty("line.separator");
creation();
name=new Someting(name);
number = new Magic(number);
}
}