• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

What are utility methods ?

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

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 ?

Thanks in advance...

Shebu
 
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
By utility methods do you mean utility classes ??

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
 
Shevesh Srivastava
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The mkdir() and mkdirs() are not essential for the usage of the core object's operation (reading, opening, writing etc... ) ..

My definition : Functions or classes are are not esstential or critical to the parent class but add useful or often used code.
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
reply
    Bookmark Topic Watch Topic
  • New Topic