Java – breaks a string into two at a hyphen
•
Java
I get the string variable from the request
String issueField = request.getParameter("issueno");
This may or may not have a hyphen in the middle I want to be able to traverse the string and split it when I see hyphens
Solution
Use string #split:
String[] parts = issueField.split("-");
Then you can use parts [0] to get the first part, the second part [1]
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码