is Repeated String - Android java.lang

Android examples for java.lang:String Join

Description

is Repeated String

Demo Code


//package com.java2s;
import android.text.TextUtils;

public class Main {

    public static boolean isRepeatedString(String str) {
        if (TextUtils.isEmpty(str)) {
            return false;
        }/*  ww w. j  av  a 2s . com*/
        int len = str.length();
        if (len <= 1) {
            return false;
        } else {
            char firstChar = str.charAt(0);
            for (int i = 1; i < len; i++) {
                char nextChar = str.charAt(i);
                if (firstChar != nextChar) {
                    return false;
                }
            }
            return true;
        }
    }
}

Related Tutorials