Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static int levelChange(String xpath1, String xpath2) {
        String[] paths1 = split(xpath1);
        String[] paths2 = split(xpath2);
        int length = Math.min(paths1.length, paths2.length);
        int index = 0;
        while (index < length && paths1[index].equals(paths2[index])) {
            index++;
        }
        return index;
    }

    public static String[] split(String xpath) {
        String[] paths = xpath.split("/");
        if (paths.length == 0) {
            paths = new String[1];
            paths[0] = "";
        }
        return paths;
    }
}