0
Please explain the function of these methods in Java?
1. x&=3 2. x|=3 3. x<<=3 4. x>>=3 Explain:- .indexOf()
4 Answers
+ 9
⢠The indexOf() method is used to get the integer value of a particular index of String type object, based on criteria specified in the parameters of the indexOf() method.
⢠The indexOf(String target) method searches left-to-right inside the given string for a "target" string. The indexOf() method returns the index number where the target string is first found or -1 if the target is not found.
String s = "Here there everywhere";
int x = s.indexOf("there"); // x is 5
int y = s.indexOf("er"); // y is 1
int z = s.indexOf("eR"); // z is -1, "eR" is not found
⢠String indexOf() method example:
https://beginnersbook.com/2013/12/java-string-indexof-method-example/
+ 1
For example
"Sololearn".indexOf("lo") returns 2
0
What about the operators from 1 to 4?
0
In the first answer, why z=-1?