check length on a integer variable? - Programmers Heaven

Howdy, Stranger!

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

Categories

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.