CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2013

    Help with findWithinHorizon

    I am new to Java and currently learning it using the dummies book. I see findWithinHorizon(".", 0).charAt(0);
    all the time, I understand that the "." is to find characters. What is the purpose of 0 and charAt(0) ?
    if i run this code on the word "forget" it will come back with only one letter "f". However if i put it in a while loop it comesback with f, o, r, g, e, t All 6 letters, why is that ?? shouldnt this statement find the first letter and not all letters??

  2. #2
    Join Date
    Jul 2001
    Sunny South Africa

    Re: Help with findWithinHorizon

    Yes, your last assumption is correct that it should find the first letter. Why? Because of the 0 you have used. The charAt(0) is IMHO overkill

    The 0 means to take the fist character

    . is a regular expression that means "1 char, whatever it is". So you're looking for the next char. So the returned string contains a single char.

    To get the next word, use Scanner.next().

    Have a look here :


  3. #3
    Join Date
    Nov 2013

    Re: Help with findWithinHorizon


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.