Java Substring

Sort by

recency

|

476 Discussions

|

  • + 0 comments

    This is a straightforward problem that helps practice working with Java’s String class. CBTF Turbo 247 Login ID and Password

  • + 1 comment
                Scanner in = new Scanner(System.in);
        String S = in.next();
        int start = in.nextInt();
        int end = in.nextInt();
        for(int i=start;i<end;i++){
            char c = S.charAt(i);
            System.out.print(c);
        }
    
  • + 1 comment

    This challenge is a great introduction to string manipulation in Java! Using the substring(int beginIndex, int endIndex) method from the String class makes this task straightforward. cricketbuzz id

  • + 0 comments

    import java.io.; import java.util.; import java.text.; import java.math.; import java.util.regex.*;

    public class Solution {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String S = in.next();
        int start = in.nextInt();
        int end = in.nextInt();
        System.out.println(S.substring(start,end));
    }
    

    }

  • + 0 comments

    It helps reinforce how indexing works in programming, especially the concept of inclusive vs. exclusive ranges. A great way to practice basic input handling and string methods! 11xplay login