+ 1
What is the meaning of
n = line.indexOf("7"); in java language.
5 odpowiedzi
+ 6
let's say for example you have a variable
String line="the 7 sins";
your variable n must be an int i suppose so if you execute this line
n = line.indexOf("7");
it will assign to n the value : 4
because that is the number of characters you need to read in order to reach the character 7.
i hope you understood my explanation.. let me know if you didn't.
+ 4
assign to variable 'n' index of first character '7' in string 'line'.
See 'methods' here: https://docs.oracle.com/javase/7/docs/api/java/lang/String.html
+ 4
it means that 'n' value will be the index of the first '7' character in the string line.
strating will be from the left to the right, and first index is 0 .
+ 1
can you post the full code please
bcs I didn't recognized "line" is?
+ 1
ofcouse Vincent is right iff the line is of string type