how to remove all characters after a certain character from a string in java code example Example: java remove character from string after String result = input.split("-")[0];