Path update

  • 9
  • Locked
Implement the changePath(String, String) method so that it replaces the jdk version in the path passed in the first method parameter with the version passed in the second parameter, and returns the new path. The JDK version starts with "jdk" and ends at "/". Example: path - "/usr/java/jdk1.8/bin" J
You can't complete this task, because you're not signed in.
Comments (1)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
Level 21 , Glasgow, United Kingdom
29 January, 21:33
Unsure why this solution isn't accepted:
public static String changePath(String path, String jdk) {
    int start = path.lastIndexOf("jdk");
    int end = path.lastIndexOf('/');
    String output = path.substring(0,start)+jdk+path.substring(end);
    return output;