# 1_JAVA I want to get the index number by specifying one character in the character string.


I will leave a note of what I learned while practicing JAVA.

What I want to do * ~ JAVA ~ *

Get the index number by specifying one character in the character string

Simply put, "I" in the "Hello" or has entered into any position! ?? It is a rudimentary problem during the rudimentary process.

☆ String.indexOf ("word you want to search")

You can get the index by using the " .indexOf "method on the string.

JAVA implementation

JAVA code

import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        //Declare a string
        String str = "Hello JAVA";
        //Get index number
        System.out.println("The index number is:"+str.indexOf("Hmm"));


The index number is:1

Now you can get the index number 1 of "n".

Recommended Posts

# 1_JAVA I want to get the index number by specifying one character in the character string.
I want to get the value in Ruby
[Ruby] I want to output only the odd-numbered characters in the character string
I want to get the IP address when connecting to Wi-Fi in Java
I want to output the character number from the left where an arbitrary character string appears.
I want to simplify the conditional if-else statement in Java
I want to find the MD5 checksum of a file in Java and get the result as a string in hexadecimal notation.
Use JLine when you want to handle keystrokes on the console character by character in Java
I want to find out if the specified character string is supported by the target character code
[Java] I want to perform distinct with the key in the object
[Android] I want to get the listener from the button in ListView
How to get the date in java
About the method to convert a character string to an integer / decimal number (cast data) in Java
I want to get the field name of the [Java] field. (Old tale tone)
I want to find out what character the character string appears from the left
I want to use java8 forEach with index
rsync4j --I want to touch rsync in Java.
[Java] How to easily get the longest character string of ArrayList using stream
I want to get a list of only unique character strings by excluding fixed character strings from the file name
[Java] I want to calculate the difference from the date
I want to use ES2015 in Java too! → (´ ・ ω ・ `)
Source used to get the redirect source URL in Java
[Java] How to cut out a character string character by character
[Kotlin] Convert ZonedDateTime to String by specifying the format
I tried to implement the Euclidean algorithm in Java
I want to get along with Map [Java beginner]
[Java] How to get the key and value stored in Map by iterative processing
[Android Studio] I want to set restrictions on the values registered in EditText [Java]
How to get the class name / method name running in Java
[Java] I want to convert a byte array to a hexadecimal number
I want to set the conditions to be displayed in collection_check_boxes
I want to call a method and count the number
I want to use the Java 8 DateTime API slowly (now)
Even in Java, I want to output true with a == 1 && a == 2 && a == 3
I tried to convert a string to a LocalDate type in Java
Change only one character from the String type string to uppercase
I want to transition to the same screen in the saved state
[Ruby on Rails] I want to get the URL of the image saved in Active Storage
In Java, I want to trim multiple specified characters from only the beginning and end.
[Swift] When you want to know if the number of characters in a String matches a certain number ...
I want to judge the necessity of testing by comparing the difference of class files when refactoring Java
When the character string passed to C ++ by JNA is garbled
Guess the character code in Java
I want to return to the previous screen with kotlin and java!
Get the current date and time by specifying the time zone in Thymeleaf
I want to convert InputStream to String
[Java] I want to check that the elements in the list are null or empty [Collection Utils]
I want to get some properties as JSON strings in Jackson!
I want to limit the input by narrowing the range of numbers
I want to display the images under assets/images in the production environment
I tried to summarize the methods of Java String and StringBuilder
I want to remove the top margin in Grouped UITableView (swift)
[Java] I tried to make a maze by the digging method ♪
[Java] How to convert from String to Path type and get the path
I want to change the value of Attribute in Selenium of Ruby
How to get the length of an audio file in java
How to increment the value of Map in one line in Java
I want to write JSP in Emacs more easily than the default.
I want to display the number of orders for today using datetime.
(Limited to Java 7 or later) I want you to compare objects in Objects.equals
Reason to add L to the number to be put in Java long type