0

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.

Vagelism
  • 601
  • 1
  • 16
  • 27

4 Answers4

4

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

Community
  • 1
  • 1
jmj
  • 237,923
  • 42
  • 401
  • 438
2

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.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
2

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);
Maxpm
  • 24,113
  • 33
  • 111
  • 170
2

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.

kant
  • 157
  • 1
  • 2
  • 15