+ 1

What is the meaning of

n = line.indexOf("7"); in java language.

14th Oct 2017, 1:52 PM
mariam_sanad
mariam_sanad - avatar
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.
14th Oct 2017, 2:35 PM
OUMAS Abdellah
OUMAS Abdellah - avatar
+ 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
14th Oct 2017, 1:55 PM
deFault
+ 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 .
14th Oct 2017, 5:17 PM
Kamal AlYafei😊
Kamal AlYafei😊 - avatar
+ 1
can you post the full code please bcs I didn't recognized "line" is?
14th Oct 2017, 1:54 PM
Nura Programmer
Nura Programmer - avatar
+ 1
ofcouse Vincent is right iff the line is of string type
14th Oct 2017, 1:57 PM
Nura Programmer
Nura Programmer - avatar