• Post Reply Bookmark Topic Watch Topic
  • New Topic

advantages and disadvantages of using static import feature of jdk 5.0  RSS feed

 
rudra tripathy
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi All,

is there any other disadvantgaes and advantages of using static import-perticualrly in large code base.

one of the concern is redability where one has to refer to top to make sure which static variable one using

Thanks in advance,
Rudra
 
Campbell Ritchie
Marshal
Posts: 56546
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the methods and fields were given good descriptive names, then it should be obvious what the names mean.

Other people will doubtless have other opinions.
 
Wendy L Gibbons
Bartender
Posts: 1111
Eclipse IDE Oracle VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in eclipse i like it, as you can simply click on the variable to get the value if that is a proble, but the code is neater.
People without good IDEs may not like it as it gives you no hint where it came from.
 
Jelle Klap
Bartender
Posts: 1952
7
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I use static imports for JUnit 4 asserts in my test cases, but beyond that I tend to avoid them altogether, for the sake of clarity.
 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To avoid namespace collisions, you should only use them for constants and static methods available in only one class. Practically, besides importing java.lang.Math.*, I don't see the point at all. And even with that class I still refuse to use static imports.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!