Java and C + + are all about substrings, C + + is substr (), Java is substring (), the use of the two is slightly different, first for the case of only one parameter:
Both S.substr (start) and s.substring (start) represent substrings starting at the start position to the end of the string
For cases with two parameters, there is a difference between the two
C + +: substr (start, Len), the starting position of the first argument, and the second argument is the length of a substring
Java:substring (start, end), the first argument is the start position, the second argument is the end position
You can refer to the following example code:
C++:
string " HelloWorld " << s.substr (44// oworcout << s.substr (4// Oworld
Java:
String s = "HelloWorld"; System.out.println (s.substring (// owor// Oworld
C + + substr () and Java substring () differences