Uppercase only the specified range with substring. (How to use substring)

/*
substring extracts characters.
The argument contains the index of the character.
* Index starts from 0
*/

/*
When there are two arguments
Example:
String str = "012345";
substring(Starting position,End position);
substring(0, 3)
The extracted characters are[012]
* The end position is 3, but it is not included in the extracted characters.

If there is one argument, it is the start position.
Example:
String str = "012345";
substring(Starting position);
substring(3);
The extracted characters are[345]
*/

/*
* Blanks are included in the index
String str = "0 12345";(Half-width blank)
substring(Starting position);
substring(3);
The extracted characters are[2345]become
*/

import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int a = sc.nextInt();
        int b = sc.nextInt();
        sc.nextLine();
        String str = sc.nextLine();
        
        System.out.println(str.substring(0, a - 1) + str.substring(a - 1, b).toUpperCase() + str.substring(b));
    }
}


Recommended Posts

Uppercase only the specified range with substring. (How to use substring)
Uppercase only the specified range with substring. (How to use substring)
ruby Uppercase letters
Explanation about Ruby Range object
How to use the link_to method
How to use the include? method
How to use the form_with method
How to use the wrapper class
How to use mssql-tools with alpine
How to cancel cell merging within a specified range with POI
How to use MinIO with the same function as S3 Use docker-compose
[Java] How to use the File class
[Rails] How to use the map method
[Java] How to use the toString () method
Studying how to use the constructor (java)
[Processing × Java] How to use the loop
[Processing × Java] How to use the class
[Processing × Java] How to use the function
How to use substring and substr methods
[Java] How to use the Calendar class
How to compare only the time with Rails (from what time to what time, something like)
How to use the camera module OV7725 (ESP32-WROVER-B)
How to use MyBatis2 (iBatis) with Spring Boot 1.4 (Spring 4)
How to use built-in h2db with spring boot
How to use Java framework with AWS Lambda! ??
Output of how to use the slice method
How to use Java API with lambda expression
How to use the replace () method (Java Silver)
How to use nfs protocol version 2 with ubuntu 18.04
[Ruby basics] How to use the slice method
How to use Map
How to use rbenv
How to use with_option
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 TreeSet
[How to use label]
How to use identity
How to use hashes
How to use Dozer.mapper
How to use Gradle
How to use org.immutables
How to use java.util.stream.Collector
How to use VisualVM
How to use Map
How to implement UICollectionView in Swift with code only
How to change the action with multiple submit buttons
How to use Oracle JDK 9 EA with Travis CI
[Rails] I don't know how to use the model ...
[Beginner] Discover the N + 1 problem! How to use Bullet
Organized how to interact with the JDK in stages
How to use JDD library in Scala with Eclipse
If you use SQLite with VSCode, use the extension (how to see the binary file of sqlite3)
How to use git with the power of jgit in an environment without git commands
How to save a file with the specified extension under the directory specified in Java to the list
Summary of how to use the proxy set in IE when connecting with Java
How to use the getter / setter method (in object orientation)
How to take a screenshot with the Android Studio emulator