Hi there, I am trying to find an explanation for what the findWithinHorizon() does. I landed on this page http://docs.oracle.com/javase/7/docs/api/ and I know that the method is part of the java.util.Scanner class (isn't it?). How do I find it in the page above please?
thanks

thanks for your help, I have found it but I am not entirely sure the API is helping me, sorry perhaps I still need to get used to the API. I have found this
reply = keyboard.findWithinHorizon(".",0).charAt(0); but I am not entirely sure I understand it. The methid takes 2 parameters (String pattern,int horizon) which in my case are "." and "0", but what do they do in my case? I mean how am I supposed to "read" this line reply = keyboard.findWithinHorizon(".",0).charAt(0);? The variable reply gets the input from the keyboard and we take what's in 0 position?
thanks

either that, or a pattern instead of a string.
no, reply only gets the very first character of the substring of the input through the keyboard, which is found by the findWithinHorizon method.

if you want to know for sure what it all does: change your input, change some of the values and use temporal variables to store the steps in between.

for instance:

String inpWithin = keyboard.findWithinHorizon(".",0);
char reply = inpWithin.charAt(0);

and print those two values. change the parameters you send to the findWithinHorizon method, and see what changes.

very important: never confuse 0 with "0", they are two completely different values: the first is a numerical value (most likely an int, which it is here), the second is an object of the type String.

ok thank you

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.