Sobes.tech
Junior — Middle

What static methods in Java are available without the need to create an instance of the class?

sobes.tech AI

Answer from AI

In Java, static methods belong to the class rather than an instance, so they can be called without creating an object. Examples of such methods:

  • Methods from the Math class, for example, Math.sqrt(), Math.abs().
  • Methods from the Collections class, for example, Collections.sort().
  • Methods from the Arrays class, for example, Arrays.asList().
  • Methods from the Integer class, for example, Integer.parseInt().

Example of calling a static method without creating an object:

int number = Integer.parseInt("123");
double root = Math.sqrt(16);

In Android, static utility methods are also frequently used, for example, TextUtils.isEmpty() or Log.d().