Languages
[Edit]
EN

Java - remove first character from string

0 points
Created by:
Emrys-Li
580

In this article, we would like to show you how to remove the first character from the string in Java.

1. Using String substring() method

In the example below, we use the String substring(int beginIndex) method, where we assign 1 to beginIndex, so we get a string without the first character.

public class StringExample {

    public static void main(String[] args) {
        String text = "ABCD";
        String substring = text.substring(1);

        System.out.println(substring); // BCD
    }
}

Output:

BCD

Reference

  1. substring() method - Oracle Docs
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.

Cross technology - remove first character from string

Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join