2
Contributors
4
Replies
6
Views
4 Years
Discussion Span
Last Post by Violet_82
0

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

1

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.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.