Showing posts with label index of. Show all posts
Showing posts with label index of. Show all posts

Get index of character from String

Complete source code below will show you, how to get index of a character from a String.

************************************************************************
COMPLETE SOURCE CODE FOR : GetIndexOfCharacterFromString.java
************************************************************************


public class GetIndexOfCharacterFromString
{
public static void main(String[]args)
{
//Create a String
String a="ABCD";

//Create an int variable that will store index for character C
int index=a.indexOf('C');

//Print index that we get
System.out.println("Index for C is : "+index);
}
}


************************************************************************
JUST COMPILE AND EXECUTE IT
************************************************************************

RELAXING NATURE VIDEO