Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

java string

  • 23-10-2011 05:55PM
    #1
    Registered Users, Registered Users 2 Posts: 2,327 ✭✭✭


    Hi, i'm new to java and have been trying to find an answer to a problem.
    I'm trying to do a check that a string variable is 16 characters long. I havent been having any luck with it so far. Would anyone have any pointers to help me?


Comments

  • Closed Accounts Posts: 20,759 ✭✭✭✭dlofnep


    Use the .length() method to determine the length of the string.


  • Closed Accounts Posts: 1,990 ✭✭✭JustAddWater


    dlofnep wrote: »
    Use the .length() method to determine the length of the string.

    Exactly. Set an int to the strings' .length() and if int == 16 then do whatever you wanted the program to do

    If your stuck, post some code and we'll take a look for you :)


  • Registered Users, Registered Users 2 Posts: 2,327 ✭✭✭deceit


    Exactly. Set an int to the strings' .length() and if int == 16 then do whatever you wanted the program to do

    If your stuck, post some code and we'll take a look for you :)

    Cool guys thanks for both your help, i've got it running :D:).


Advertisement