Update Algorithm.java

I wish to bring your attention, on the fact
you asked me to write a METHOD not an Application.
Otherwise it could be implemented using some design pattern.