Can anyone explain me what are utility methods, why are they called so and whats the difference between them and other *should I call* methods. And yes while writing this query I also remember from collections framework that there are also some methods that we call Algorithms and to some methods we simple call them methods.. so what the difference between them ?
In that case, the java.io.Collections class for instance is a utility class.
These classes contain methods that you could easily create yourself, there is not much logic behind them, but they come in handy and you need to use them quite often so the designers decided to include them in the Java API
JDBCSupport - An easy to use, light-weight JDBC framework -
Joined: Jan 19, 2010
for example, mkdir and mkdirs in FIle class are called utility classes.
second, methods like that for binarysearch and all are called algorithms and methods like add(object) is not.
I regard mkdir() as an essential (or maybe a better word: "primitive") method. Without it, how would you create a folder? In other words, for me a utility method is a method that cannot be expressed using other (public) methods.
mkdirs() on the other hand can be implemented using (for instance) getParentFile() and mkdir() so that is indeed a utility method.