Demonstrating package names collision in java -
i got question assignment:
packages/naming
we have created lot of packages , defined classes , interfaces in them. have discussed point have remember while naming them. in assignment see how important naming is.
please change package names in previous assignment such 2 packages have same name , analyze result/errors thrown.
my doubt:
i unable think of way(scenario) demonstrate has been asked. since java imports absolute, situation described in question seem impossible produce (imo).
please me demonstrate thing.
thanks in advance :)
that depend heavily on code you're running.
the way cause package name conflict put 2 separate jars on classpath both contain classes in same package. if none of class names conflict, there no conflict. if class names conflict, jvm try load them jar comes earlier in classpath. errors occur when classes in later jar, , classes in later jar use classes names used in earlier jar. nature of error depends on type of use.
(i should clarify answer applies pure java, , has no relation how particular ide or build system might generate jars project.)
Comments
Post a Comment