Tested with other conditions mentioned elsewhere:
"/usr/java/jdk1.8/bin"
"/usr/java/jdk/bin"
"/usr/java/jdk1.8-beta/bin"
and I get the
"/usr/java/jdk-13/bin" as asked by the problem
What am I missing? (I removed some out of bounds checks from the code just to simplify things on read).
package en.codegym.task.pro.task09.task0914;
/*
Path update
*/
public class Solution {
public static void main(String[] args) {
String path = "/usr/java/jdk1.8/bin";
String jdk13 = "jdk-13";
System.out.println(changePath(path, jdk13));
}
public static String changePath(String path, String jdk) {
String[] parts = path.split("jdk");
String endPart = parts[1].substring(parts[1].indexOf("/"));
return parts[0] + jdk + endPart;
}
}