判断邮件的格式是否含有@:挖掘基本功

判断一个字符串中是否含有@

private boolean isEmailValid(String email) {
    //TODO: Replace this with your own logic
    return email.contains("@");
}
*************************************************************************

/**
 * Determines if this {@code String} contains the sequence of characters in
 * the {@code CharSequence} passed.
 *
 * @param cs
 *            the character sequence to search for.
 * @return {@code true} if the sequence of characters are contained in this
 *         string, otherwise {@code false}.
 * @since 1.5
 */
public boolean contains(CharSequence cs) {
    if (cs == null) {
        throw new NullPointerException("cs == null");
    }
    return indexOf(cs.toString()) >= 0;
}
*****************************************************************************

public int indexOf(String string) {
    int start = 0;
    int subCount = string.count;
    int _count = count;
    if (subCount > 0) {
        if (subCount > _count) {
            return -1;
        }
        char[] target = string.value;
        int subOffset = string.offset;
        char firstChar = target[subOffset];
        int end = subOffset + subCount;
        while (true) {
            int i = indexOf(firstChar, start);
            if (i == -1 || subCount + i > _count) {
                return -1; // handles subCount > count || start >= count
            }
            int o1 = offset + i, o2 = subOffset;
            char[] _value = value;
            while (++o2 < end && _value[++o1] == target[o2]) {
                // Intentionally empty
            }
            if (o2 == end) {
                return i;
            }
            start = i + 1;
        }
    }
***************************************************************************

public int indexOf(int c, int start) {
    if (c > 0xffff) {
        return indexOfSupplementary(c, start);
    }
    return fastIndexOf(c, start);
}
--------------------------------------------------------------------------------

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值