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)
Ruby uppercase only specified range
How to use the link_to method
How to use the include? 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
[Java] How to use the hasNext function
How to use BootStrap with Play Framework
[Rails] How to use rails console with docker
[Java] How to use the HashMap 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)
[Java] How to use Thread.sleep to pause the program
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! ??
[Swift] How to link the app with Firebase
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
How to use docker compose with NVIDIA Jetson
How to use nginx-ingress-controller with Docker for Mac
[Ruby basics] How to use the slice method
How to use Map
How to use rbenv
How to use letter_opener_web
How to use with_option
How to use fields_for
How to use java.util.logging
How to use collection_select
How to use Twitter4J
How to use active_hash! !!
How to use MapStruct
How to use hidden_field_tag
How to use TreeSet
[How to use label]
How to use identity
How to use hashes
How to use JUnit 5
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
How to use Z3 library in Scala with Eclipse