Vagelism
Vagelism

Reputation: 601

Error Using the boolean

I try to use the boolean in my class and get this message

"reference to Boolean is ambiguous, both class jxl.write.Boolean in jxl.write and class java.lang.Boolean in java.lang match"

What can I do in order not to take this error? Thank you in advance.

Upvotes: 0

Views: 739

Answers (4)

kant
kant

Reputation: 157

You see this message because two classes with equal simple names are vsible in one place and java cannot decide which to use. you can specify fully qualified class name (java.lang.Boolean or jxl.write.Boolean depending on which you need) or may be just remove import for jxl.write.Boolean in case you don't really need it.

Another option (if you do need jxl.write.Boolean but use it not very often) is to remove import for jxl.write.Boolean and explicitly use fully specified name for it when you need it.

Upvotes: 2

Maxpm
Maxpm

Reputation: 25642

The compiler sees two imported classes that have the name Boolean. Tell it which one to use by fully-qualifying it:

java.lang.Boolean myBoolean = new java.lang.Boolean(true);

Upvotes: 2

David Heffernan
David Heffernan

Reputation: 613592

You need to fully qualify the type name. For example by using java.lang.Boolean in place Boolean. Or jxl.write.Boolean in the unlikely event that you want the other one.

Upvotes: 2

Jigar Joshi
Jigar Joshi

Reputation: 240996

Just use

java.lang.Boolean instead of Boolean

From the error message it seems there are two imports of class Boolean

1 by default java.lang.* 2 jxl.write.Boolean

So you have to mention explicitly which Boolean you are referring in order to help compiler solve the ambiguity


Also See

Upvotes: 4

Related Questions