double population = 7000000000;
long population2 =  7000000000;

I have to write down world population, so i used both double and long primitive types. However, both of them says that this number is out of range. What can i do with this? i made a google search but it says that long primitive type is supposed to be accepted. Can anybody please help me ?

Recommended Answers

All 4 Replies

What does "not accept" mean? Do you get error messages? If so, please post them.

The numbers as you have written them are int values. There are suffixes you can put on a number to make it a double or long.

The numbers as you have written them are int values. There are suffixes you can put on a number to make it a double or long.

this is the error message when i used double,

Exception in thread "main" java.lang.Error: Unresolved compilation problem: 
    The literal 7000000000 of type int is out of range 

    at InterestTest.main(InterestTest.java:4)

you used int, you need to add a 'L' at the end of the number 'l' is ok but it also looks like '1' so use 'L' for lond and 'D' for double. again 'd' works fine, it may not look like any number try to be consistant with you case.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.