I currently have an ArrayList of strings in Java, but I would like to truncate (or limit) the number of characters in each strings to 20. I couldn’t find a method to do so.
Example:
"hello this is one of the descriptions in an array list, please limit me to 20"
should become:
"hello this is one of"
Some possible ways:
add(...)methods. I don’t like this.ArrayList<String>but instead anArrayList<MyCustomClass>where MyCustomClass’s constructor or setter methods truncate the Strings as needed. I like this one too!