У нас вы можете посмотреть бесплатно How To Find The Index Position Of A Substring Or A Specific Character In A String Using The Java ind или скачать в максимальном доступном качестве, которое было загружено на ютуб. Для скачивания выберите вариант из формы ниже:
Если кнопки скачивания не
загрузились
НАЖМИТЕ ЗДЕСЬ или обновите страницу
Если возникают проблемы со скачиванием, пожалуйста напишите в поддержку по адресу внизу
страницы.
Спасибо за использование сервиса savevideohd.ru
How To Find The Index Position Of A Substring Or A Specific Character In A String Using The Java indexOf() Method In this video, we will have a look at the Java indexOf() method which is used to find the index position of a substring or a specific character in a String. One thing to note is that this method returns an integer value that represents the index position of the substring or the character. There are actually two variations of this method in the String class 1. In the first example, I will show you how to return the index position of the first occurrence of a character in a given String String str = “I love programming”; Since the method returns an integer value, I will declare an integer variable to store the value returned whenever the method is called and executed And also, we have to note that this method can return both the index of a character and of a substring int returned_value = str.indexOf(‘p’); int returned_value2 = str’.indexOf(“love”); System.out.println(“The index position is : “ + returned_value); System.out.println(“The index position is : “ + returned_value2); 2. In the second example, I will show you how to return the index of the first occurrence of a character or substring in a given String after a specified index position. String str = “I love programming”; Since the method returns an integer value, I will declare an integer variable to store the value returned whenever the method is called and executed int returned_value = str.indexOf(‘o’ , 4); int returned_value2 = str.indexOf(“love” , 4); System.out.println(“The index position is : “ + returned_value); System.out.println(“The index position is : “ + returned_value2); 4 here represents the specified index position from where the method will start looking for the character o. Also, the method will return -1 if the character or the substring is not found in the given String. That’s why we get -1 in the second statement #codingriver #java #programming