Question: I'm trying to print a large integer in java but it is giving me a compiling error which is: error: integer number too large: 9999999999999

I'm trying to print a large integer in java but it is giving me a compiling error which is:

error: integer number too large: 9999999999999

this is how I initialized the number:

long c = 9999999999999;

my question is why is it not working with "long" data type knowing that long can hold up to 19 digits?

to be specific, long can hold up to: 9223372036854775807

I know that there is a BigInteger class that I can import and use it but my question is why is it not working with long?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!