判断字符串中是否有重复字母

来源:互联网 发布:瓦拉内fifa数据 编辑:程序博客网 时间:2024/04/30 14:42
package com.demo.four;import org.junit.Test;public class test {/** * 判断字符串中是否有重复字母 */@Testpublic void test(){System.out.println(checkDifferent("abcdefghijk"));}public boolean checkDifferent(String iniString){boolean isbool = false;char[] chars = iniString.toCharArray();for (int i = 0; i < chars.length; i++) {for (int j = i+1; j < chars.length; j++) {if(chars[i] == chars[j]){isbool = true;return isbool;}else {isbool = false;}}}return isbool;}}

0 0
原创粉丝点击