Java tutorial
//package com.java2s; //License from project: Open Source License public class Main { public static String getQuanBuFenLeiName(String[] choices, String defaultQuanbufenlei, String defaultItemName) { if (choices.length < 3) { return defaultQuanbufenlei; } if (choices[0].equals(defaultItemName) && choices[1].equals(defaultItemName) && choices[2].equals(defaultItemName)) { return defaultQuanbufenlei; } else { StringBuilder sb = new StringBuilder(); for (int i = 0; i < choices.length; i++) { if (!choices[i].equals(defaultItemName)) { sb.append(choices[i] + "/"); } } sb.deleteCharAt(sb.length() - 1); return sb.toString(); } } }