Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Implicit conversion between Double and double
icon5.gif  Implicit conversion between Double and double [message #731813] Mon, 03 October 2011 07:59 Go to next message
Sayan Mukherjee is currently offline Sayan MukherjeeFriend
Messages: 2
Registered: October 2011
Location: Mumbai, India
Junior Member
I am getting different behaviour in two different Eclipse installations:

Env A -> JDK 7.0, JRE 7.0 and Eclipse Galileo
Env B -> JDK 1.6.0_03, JRE 1.6.0_03 and Eclipse Pulsar

The code:
	Double d1 = new Double(1.234); /* Line 1 */
	double d = 7.32;	       /* Line 2 */
	Double d2 = d1 + d;            /* Line 3 */


In Env A:
When I try to compile the above code, I get a Eclipse compile error in Line 3 saying the operator '+' cannot add 'Double' with 'double'. Eclipse shows a red marker under the '+' sign.

In Env B:
THE CODE WORKS!

I think it is NOT an issue with JSE/JDK version - it is possibly some config in Eclipse. Can somebody tell me what is this config so that code can compile in Eclipse Galileo?

Thanks in advance.

Sayan

[Updated on: Mon, 03 October 2011 08:00]

Report message to a moderator

Re: Implicit conversion between Double and double [message #732057 is a reply to message #731813] Mon, 03 October 2011 19:53 Go to previous messageGo to next message
Sayan Mukherjee is currently offline Sayan MukherjeeFriend
Messages: 2
Registered: October 2011
Location: Mumbai, India
Junior Member
I found the reason of the code not compiling in my setup of Eclipse Galileo.

The config parameter is here:
Project -> Properties -> Java Compiler


There is a group box called JDK Compliance, possibly to provide backward compatibility.

The property Compiler Compliance Level should be set to 1.5 or above for the implicit coversion between primitives and their wrappers to work.

Mine was set to 1.4!!!
Re: Implicit conversion between Double and double [message #733640 is a reply to message #732057] Wed, 05 October 2011 09:30 Go to previous message
java_fan  is currently offline java_fan Friend
Messages: 11
Registered: September 2011
Junior Member
Sayan Mukherjee wrote on Mon, 03 October 2011 15:53


The property Compiler Compliance Level should be set to 1.5 or above for the implicit coversion between primitives and their wrappers to work.



You're right. I sometimes got the same problem.

java collection

[Updated on: Sun, 04 December 2011 23:26]

Report message to a moderator

Previous Topic:Bindings order?
Next Topic:Hudson and Continuous Deployment
Goto Forum:
  


Current Time: Thu Apr 25 07:36:00 GMT 2024

Powered by FUDForum. Page generated in 0.02850 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top