Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
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,326 ✭✭✭


    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,326 ✭✭✭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