Help with findWithinHorizon
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Help with findWithinHorizon

  1. #1
    Join Date
    Nov 2013
    Posts
    2

    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
    Location
    Sunny South Africa
    Posts
    11,098

    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 :

    http://www.tutorialspoint.com/java/u...zon_string.htm

  3. #3
    Join Date
    Nov 2013
    Posts
    2

    Re: Help with findWithinHorizon

    Thanks!!!!!!

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

This is a CodeGuru survey question.


Featured


HTML5 Development Center