Answer the question
In order to leave comments, you need to log in
Why can't the class name be omitted for a static method?
Good day.
There is an example of a method that sorts a list using the static sort() and reverseOrder() methods. They are written with reference to the Collections class:
Collections.sort(copy, Collections.reverseOrder());
Collections.sort(copy, reverseOrder());
Answer the question
In order to leave comments, you need to log in
Because you imported the package java.util
that contains the class Collections
, and when you use it, you specify the name of the entire class. If you want to do as you said, then you need to use a static import. Those. addimport static java.util.Collections.reverseOrder;
I recommend reading about static import. I think this will help you for your specific task.
If, in essence, to implement your Wishlist, it is necessary to bypass all classes in the classpath during compilation and check for the presence of this function there, and only after that write a call to a specific function into the bytecode.
In addition, it is not clear how to work with collisions.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question