Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java: Succinct way to import multiple constants

Tags:

java

android

Is there a succinct way to import in Java which would be equivalent to the following statement:

import static android.view.View.GONE;
import static android.view.View.INVISIBLE; 
import static android.view.View.VISIBLE;

I know about this:

import android.view.View.*;

But I would like to be able to control what I import, and not just import everything in the View namespace.

ANSWER: The answer is No.

like image 713
tjb Avatar asked Jul 24 '26 01:07

tjb


1 Answers

No, there's no quicker way to only import some constants. You can get them all, or you can list each one you want separately.


Actually there is technically a third option, not that it's necessarily better. You do have the option to import none of them and use their fully qualified name each time you refer to them.

like image 51
Brad Mace Avatar answered Jul 25 '26 15:07

Brad Mace



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!