Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.util.Set;

public class Main {

    public static String ensureUnique(Set<String> nameSet, String name) {
        String paramName = name;
        if (null != paramName && -1 != paramName.indexOf(".")) {
            paramName = paramName.replace('.', '_');
        }
        if (nameSet.contains(paramName)) {
            int index = 1;
            String tempVar = null;
            while (true) {
                tempVar = paramName + "_" + index;
                if (!nameSet.contains(tempVar)) {
                    break;
                }
                index++;
            }
            paramName = tempVar;
        }
        return paramName;
    }
}