Question

Is there a way to shorten type names in java. Something similar to typedef in c++ or similar to the usage of namespaces?
For example if I have the type "org.w3c.dom.Node" and I don't want to write
that full name every time, but also don't want to do import on the whole file
but just localy define the type of "Node" to be "org.w3c.dom.Node" on one method?

Était-ce utile?

La solution

No, there's no way to create an alias "locally" (I take it by "locally" you mean within a method, since you said you don't want to do an import at the top of the file, which is "local" to the file).

Autres conseils

You don't want to import that class for the whole file, but what about moving the method(s) that require org.w3c.dom.Node to a new file that does have that import?

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top