Removing the first 3 characters from a string

JavaString

Java Problem Overview


What is the most efficient way to remove the first 3 characters of a string?

For example:

'apple' change to 'le'
'a cat' change to 'at'
' a b c'change to 'b c'

Java Solutions


Solution 1 - Java

Just use substring: "apple".substring(3); will return le

Solution 2 - Java

Use the substring method of the String class :

String removeCurrency=amount.getText().toString().substring(3);

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionkafter2View Question on Stackoverflow
Solution 1 - JavaSergey VedernikovView Answer on Stackoverflow
Solution 2 - JavaDeepak SharmaView Answer on Stackoverflow