If you want to parse the number after the v as an int and increment it by 1, just do so by substringing, adding 1 to the number and concatenating the resulting incremented number back into a string with "v" prepended:
String version = "v1";
String newVersion = "v" + (Integer.parseInt(version.substring(1,version.length()))+1);
System.out.println(newVersion);
Alternatively, you could keep track of the current version in an int
, increment that and construct your new String
by appending that int to a "v", without having to call substring()
.