Languages
[Edit]
EN

Java - remove first character from string

0 points
Created by:
Emrys-Li
380

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
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