Hello!
My solution isn't validate from the compiler. Why?
Thanks a lot!
package en.codegym.task.pro.task09.task0914;
/*
Path update
*/
public class Solution {
public static void main(String[] args) {
String path = "/usr/java/jdk5/bin";
String jdk13 = "jdk-8";
System.out.println(changePath(path, jdk13));
}
public static String changePath(String path, String jdk) {
//write your code here
int index1 = path.indexOf("/");
int index2 = path.indexOf("/", index1 + 1);
int index3 = path.indexOf("/", index2 + 1);
String stringBeforeJdk = path.substring(0, index3 + 1);
int index4 = path.lastIndexOf("/");
String stringAfterJdk = path.substring(index4);
return stringBeforeJdk + jdk + stringAfterJdk;
}
}