• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

static import without package  RSS feed

 
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to use static import from a class that are not in the package?

all my java/classes are in one folder, no package.

I can access it with ClassName.staticMember.

but want to remove the ClassName. is it possible

thanks
 
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think that you're explaining something not related to your question
First, you're talking about packages, and then about removing the classname to access static members.

1. you should always put classes into packages. Keep things clean, this will avoid you troubles
2. You cannot remove the class name to access static members.
 
Ranch Hand
Posts: 1608
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
They are in a package - it's called the "default" package.
You cannot use a static import (or any import at all in fact) from the default package. This is exactly one reason why should always use a package declaration - you force all clients of the type to also exist in the default package.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!