remove subString from a String in the middle - Java java.lang

Java examples for java.lang:String Substring

Description

remove subString from a String in the middle

Demo Code

//package com.java2s;

public class Main {
    public static void main(String[] argv) {
        String string = "java2s.com";
        int start = 42;
        System.out.println(remove(string, start));
    }//w w  w.ja  v  a  2s  .  c om

    public static String remove(String string, int start) {
        return string.substring(0, start);
    }

    public static String remove(String string, int start, int count) {
        return string.substring(0, start) + string.substring(start + count);
    }
}

Related Tutorials