get first character of string java
var string = "freeCodecamp";
string.charAt(0); // Returns "f"
get first character of string java
var string = "freeCodecamp";
string.charAt(0); // Returns "f"
String indexOf(String str int fromIndex) method in java
import java.util.*;
public class StringIndexOfMethodExample
{
public static void main(String[] args)
{
String strInput = new String("hello world core java");
String strSub = new String("core");
System.out.print("Index found: " );
System.out.println(strInput.indexOf(strSub, 3));
}
}
java indexof not found
The java string indexOf() method returns index of given character value or substring. If it is not found, it returns -1. The index counter starts from zero.
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us