How to have conditional imports in Java like we have the ifdefs
in C
This is what I intend to achieve
ifdef TEST
import com.google.mystubs.swing;
elif
import javax.swing.*;
endif
You don't have conditional import with java
But you could conditionally use different classes with same name using fully qualified name
for example:
if(useSql){
java.sql.Date date = new java.sql.Date()
}else{
java.util.Date date = new java.util.Date()
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With