1

So let's say I have different - independent - classes which use the same couple of imports over and over. let's say I need to import these lines for couple of classes to create APIs:

import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

What's the best practice for these imports? should I use them as is (which obviously increases the LOC) , or should I somehow group them together and create a new package and just import the package?

I assume using * would not be suggested for couple of reasons (readability etc)

Thanks in advance

Mahyar
  • 1,011
  • 2
  • 17
  • 37
  • 2
    LOC does not matter. How do you plan to import several classes without using `*`? And also, because modern IDEs places imports automatically, I do not think this is a real problem – awesoon May 10 '18 at 05:56
  • 1
    Use them as is, an IDE will collapse down the imports anyway so won't affect how much clutter there is in your class. – Iain Duncan May 10 '18 at 05:56
  • Yes, don't worry about LOC and things that can be automated by your IDE. For an eclipse example, [see this answer](https://stackoverflow.com/a/234625/1110636) – Timir May 10 '18 at 06:05

0 Answers0