chiragkini Posted July 20, 2009 Share Posted July 20, 2009 Hi Guys!I am new to Jaspers IReport . I use this in netbeans 6.5 for reporting but I am facing one problem------>>>I have two fields whose Expression class java.lang.Double, whose values are taken from database.Now I want to add those two fields and display in Third Field, But whenever I use + operator to add those two fields in third field expression it gives me error " The operator + is undefined for the argument type(s) java.lang.Double, java.lang.Double"I dont know why its not allowing to add two Double fields.. So please guys help me out with this problem....Thanks in Advance... Link to comment Share on other sites More sharing options...
oxelad Posted July 21, 2009 Share Posted July 21, 2009 you can solve this by using an expression like this "variable1.doubleValue()+variable2.doubleValue()" Link to comment Share on other sites More sharing options...
chiragkini Posted July 22, 2009 Author Share Posted July 22, 2009 Thanks Oxelad, But when I tried to do this it gives me error saying "Cannot cast from double to Double" so even if when i tried to convert values first into string the convert into double it fails. For eg. when i do ($f{variable1}.toString()).doubleValue() +($f{variable2}.toString()).doubleValue() , it gives me error: "The method doubleValue() is undefined for type String.... Note: my variable values comes from database tables of type DOUBLE. Hope u got it what is scenario... Link to comment Share on other sites More sharing options...
oxelad Posted July 22, 2009 Share Posted July 22, 2009 It is a Java. Ok. The correct code should be like this one: Double.valueOf($f{variable1}.doubleValue()+$f{variable2}.doubleValue()) Link to comment Share on other sites More sharing options...
chiragkini Posted July 22, 2009 Author Share Posted July 22, 2009 Hey Thanks Oxelad, thanks a ton. Its working now, actually I was doing stupiity by using Double.valueOf($f{variable1}.doubleValue()) + Double.valueOf($f{variable2}.doubleValue()). I got my mistake ... Thanks once again :) Link to comment Share on other sites More sharing options...
tomcushing70 Posted March 28, 2012 Share Posted March 28, 2012 Oxelad. Thanks a lot. I am constantly struggling with Java in Jasper. This helped me a lot. I think this will save me lots of time in the future. Link to comment Share on other sites More sharing options...
shareef.hiasat Posted June 28, 2014 Share Posted June 28, 2014 new Double( $f{variable1}.doubleValue()+$f{variable2}.doubleValue()) would work too Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now