0

Let's say I have a class like below

public class ClassDemo {
/*
   private String getData() {
      String s = "testClass";
      return s;
   }
*/
}

In the above class the only method it has was commented out. This is literally useless. Since I have a lot of classes in a package it's not easy to identify as there is no dependency on this class or methods inside this class.

I use Maven to build. Is there a way to identify such classes?

I understand it's possible to achieve that using eclipse. But is there a way to detect that in build tools like Maven, Ant etc?

Damien-Amen
  • 7,232
  • 12
  • 46
  • 75

1 Answers1

-1

The class named java.lang.Class has a lot of goodies available, such as getFields(), getConstructors(), getMethods(), getClasses(), getInterfaces(), getAnnotations()... etc. If the length of the array is zero, then there is none in that class.

Edit: Just use the getClass() method in java.lang.Object

GalAbra
  • 5,048
  • 4
  • 23
  • 42
user3376587
  • 134
  • 2
  • 12