0

Please explain the function of these methods in Java?

1. x&=3 2. x|=3 3. x<<=3 4. x>>=3 Explain:- .indexOf()

1st Jan 2019, 2:14 PM
Prince Gupta
Prince Gupta - avatar
4 odpowiedzi
+ 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/
1st Jan 2019, 2:43 PM
Danijel Ivanović
Danijel Ivanović - avatar
+ 1
For example "Sololearn".indexOf("lo") returns 2
1st Jan 2019, 2:48 PM
Gordon
Gordon - avatar
0
What about the operators from 1 to 4?
1st Jan 2019, 3:37 PM
Prince Gupta
Prince Gupta - avatar
0
In the first answer, why z=-1?
1st Jan 2019, 3:38 PM
Prince Gupta
Prince Gupta - avatar