3

This could be basic question but I could not find something useful.

Question is: How to convert double or int value to Number type ( to be more specific oracle.jbo.domain.Number)

I tried the following:

for integer values

         int i=9;
         Integer y=new Integer(i);
         oracle.jbo.domain.Number num=(oracle.jbo.domain.Number)y;

for float values

         double i=9.5;
         Double y=new Double(i);
         oracle.jbo.domain.Number num=(oracle.jbo.domain.Number)y;

But I always get incompatible types error in both cases:

Type 'oracle.jbo.domain.Number' incompatible with 'java.lang.Integer'

and

Type 'oracle.jbo.domain.Number' incompatible with 'java.lang.Double'

if the conversion did not work, then how to simply create Number object in java

2 Answers 2

8

You do not need to cast it. just use constructor of Number class.

int value = 5;
oracle.jbo.domain.Number num = new oracle.jbo.domain.Number(value);
Sign up to request clarification or add additional context in comments.

Comments

5

Take a look at documentation. You can construct new Number objects like so:

Number dNumber = new Number(9.5);
Number iNumber = new Number(9);

2 Comments

Today the class Number is abstract. Doesn't can be instantiated.
@rplaurindo Any other way to do it?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.