[Java] How to cut out a character string character by character

Here is a brief summary of how to cut out characters one by one.

Source code example

class Main{
public static void main(String[] args) {

    //Character string to cut out
    String text = "abcde";
    
    char[] work = new char[text.length()];

    for(int i = 0; i < text.length(); i++){
            work[i] = text.charAt(i);

            //Output the cut out character string character by character
            System.out.println(work[i]);
        	}
	}
}

Output result

a
b
c
d
e

Another option is to use substring.

Recommended Posts

[Java] How to cut out a character string character by character
[Java] How to use substring to cut out a part of a character string
[Java] How to erase a specific character from a character string
[Java] How to convert a character string from String type to byte type
[Java] Divide a character string by a specified character
[Android] How to convert a character string to resourceId
Cut out a Ruby string
[Java] How to get a request by HTTP communication
How to make a Java container
[Java] How to create a folder
How to make a Java array
How to store a string from ArrayList to String in Java (Personal)
[Java] Cut out a part of the character string with Matcher and regular expression
How to make a Java calendar Summary
[Introduction to Java] How to write a Java program
How to make a Discord bot (Java)
How to output Java string to console screen
How to print a Java Word document
How to check for the contents of a java fixed-length string
How to find out the Java version of a compiled class file
[Java] How to get to the front of a specific string using the String class
How a completely inexperienced person studied to acquire Java silver by himself
How to track when a bucket managed by scoop changes (mainly Java)
[java] Summary of how to handle character strings
How to display a web page in Java
Code to escape a JSON string in Java
How to convert a solidity contract to a Java contract class
[Ruby] How to generate a random alphabet string
How to write Java String # getBytes in Kotlin?
[Java] How to convert one element of a String type array to an Int type
[Java] How to easily get the longest character string of ArrayList using stream
[Ruby] Cut out a string using the slice method
How to create a Java environment in just 3 seconds
How to jump from Eclipse Java to a SQL file
<Java> Quiz to batch convert file names separated by a specific character string with a part of the file name
java: How to write a generic type list [Note]
[Java] How to play rock-paper-scissors (equivalent to paiza rank A)
How to create a data URI (base64) in Java
[Java] How to execute tasks on a regular basis
How to convert A to a and a to A using AND and OR in Java
How to convert a file to a byte array in Java
[Java] How to start a new line with StringBuilder
(Java) How to implement equals () for a class with value elements added by inheritance
# 1_JAVA I want to get the index number by specifying one character in the character string.
[Java] How to use Map
How to lower java version
[Java] How to use Map
How to uninstall Java 8 (Mac)
Java --How to make JTable
How to write java comments
How to leave a comment
How to use java class
[Ruby] How to comment out
[Java] How to use Optional ②
[Java] How to use removeAll ()
[Java] How to display Wingdings
How to use String [] args
How to use Java Map
How to set Java constants
How to use Java variables
How to convert Java radix