You can use string.indexOf('a')
.
If the char a
is present in string
:
it returns the the index of the first occurrence of the character in
the character sequence represented by this object, or -1 if the
character does not occur.
More Related Contents:
- Java – how to replace duplicated characters in a string? [closed]
- Replace a character at a specific index in a string?
- What is the easiest/best/most correct way to iterate through the characters of a string in Java?
- Remove all occurrences of char from string
- Java String remove all non numeric characters but keep the decimal separator
- How to compare character ignoring case in primitive types
- Converting String to “Character” array in Java
- Creating Unicode character from its number
- How to determine if a String has non-alphanumeric characters?
- Java: How to split a string by a number of characters?
- Validating IPv4 string in Java
- Need some advice on split() method in Java [closed]
- Is there a way to instantiate a class by name in Java?
- Check if String contains only letters
- Check string for palindrome
- Immutable class?
- Binary to text in Java
- Why is String immutable in Java?
- Compare one String with multiple values in one expression
- Replace the last part of a string
- Extract time from date String
- Java String Scanner input does not wait for info, moves directly to next statement. How to wait for info? [duplicate]
- Cleanest way to build an SQL string in Java
- Creating a UUID from a string with no dashes
- String concatenation containing Arabic and Western characters
- What is the character encoding of String in Java?
- What’s the quickest way to compare strings in Java?
- Random element from string array [closed]
- Hints for java.lang.String.replace problem? [duplicate]
- What is difference between mutable and immutable String in java