Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

check length on a integer variable?

harukiharuki Posts: 1Member
I have a declared
[code]int IntLength=1234;[/code]

how can i check the length on this, how many letters there are?

you can use .length on string variables, but cant find out how do make it work on a integer.

sincerely h

Comments

  • HackmanCHackmanC Posts: 441Member
    [code]int intLenght=1234;
    System.out.println("The length:" + String.valueOf(intLenght).trim().length());
    [/code]

    Convert to a string, trim the leading and trailing spaces, then get the length of such string.
    [red]Good luck![/red]
    [blue]Hackman[/blue]
Sign In or Register to comment.