Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Java
  4. large numbers

large numbers

Scheduled Pinned Locked Moved Java
c++javaquestion
3 Posts 3 Posters 13 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mike7411
    wrote on last edited by
    #1

    How do you separate large numbers in Java? I want to use something like commas. I think this works in C++, but it doesn't work in Java:

    int onebillion = 1'000'000'000;

    Anyone know? Thanks.

    P L 2 Replies Last reply
    0
    • M mike7411

      How do you separate large numbers in Java? I want to use something like commas. I think this works in C++, but it doesn't work in Java:

      int onebillion = 1'000'000'000;

      Anyone know? Thanks.

      P Offline
      P Offline
      Pete OHanlon
      wrote on last edited by
      #2

      From Java 7 onwards, you can use the underscore in numeric literals. For instance, 1 million would be represented as 1_000_000. Documentation for this feature can be found here[^].

      Advanced TypeScript Programming Projects

      1 Reply Last reply
      0
      • M mike7411

        How do you separate large numbers in Java? I want to use something like commas. I think this works in C++, but it doesn't work in Java:

        int onebillion = 1'000'000'000;

        Anyone know? Thanks.

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        See Java Tutorials Learning Paths[^] and also Overview (Java SE 18 & JDK 18)[^].

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups