How to use submit method (Java Silver)

What is the substring method?

A method to get an arbitrary subsequence from a string. For example, from the string "It's nice weather today", just the string "Weather" Can be extracted.

String class methods java.lang.String.substring()

substring: Substring, substring, substring

How to use


public static void main(String[] args) {
	//Character string before extraction
	String str = "abcde";
	//Display the extracted character string
	System.out.println(str.substring(2,4));
  }

Execution result

	cd

To specify the character string to be extracted, draw a line between the characters as shown below. It is easy to understand if you number it.

|a|b|c|d|e|    0 1 2 3 4 5

|now|Day|Is|I|I|Heaven|Qi|so|Su|Ne| 0 1 2 3 4 5 6 7 8 9 10

If you specify only the start position and not the end position, the remaining sedge characters are extracted.


public static void main(String[] args) {
	//Character string before extraction
	String str = "The weather is good today, is not it";
	//Display the extracted character string
	System.out.println(str.substring(5));
  }

Execution result

It's the weather

Recommended Posts

How to use submit method (Java Silver)
How to use the replace () method (Java Silver)
[Java] How to use join method
[Java] How to use the toString () method
[Java] How to use Map
[Java] How to use Map
How to use java class
[Java] How to use Optional ②
[Java] How to use removeAll ()
[Java] How to use string.format
How to use Java Map
How to use Java variables
[Java] How to use Optional ①
[Java] How to use compareTo method of Date class
How to study Java Silver SE 8
How to use Java HttpClient (Get)
How to use the form_with method
How to use Java HttpClient (Post)
[Processing × Java] How to use variables
[Ruby] How to use any? Method
[Java] How to use LinkedHashMap class
[JavaFX] [Java8] How to use GridPane
How to use class methods [Java]
[Java] How to use List [ArrayList]
How to use classes in Java?
How to pass Oracle Java Silver
[Processing × Java] How to use arrays
How to use Ruby inject method
How to use Java lambda expressions
[Java] How to use Math class
How to use Java enum type
Multilingual Locale in Java How to use Locale
[Java] How to use the HashMap class
[Rails] How to use the map method
[Easy-to-understand explanation! ] How to use Java instance
Studying how to use the constructor (java)
[Processing × Java] How to use the loop
How to use Java classes, definitions, import
[Easy-to-understand explanation! ] How to use Java polymorphism
[Java] [Maven3] Summary of how to use Maven3
[Processing × Java] How to use the class
How to use Java Scanner class (Note)
[Processing × Java] How to use the function
[Easy-to-understand explanation! ] How to use ArrayList [Java]
[Java] How to use the Calendar class
[Rails] How to use helper method, confimartion
[Java] Learn how to use Optional correctly
[Easy-to-understand explanation! ] How to use Java overload
try-catch-finally exception handling How to use java
[Easy-to-understand explanation! ] How to use Java encapsulation
How to use Map
How to use rbenv
How to use letter_opener_web
How to use fields_for
How to use java.util.logging
How to use map
How to use collection_select
How to use Twitter4J
How to use active_hash! !!
How to use MapStruct
How to use hidden_field_tag