Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import android.text.TextUtils;

public class Main {

    public static String getStarMobile(String mobile) {
        if (TextUtils.isEmpty(mobile))
            return "";
        int length = mobile.length();
        if (length == 11) {
            StringBuilder builder = new StringBuilder();
            builder.append(mobile.substring(0, 3)).append("****").append(mobile.substring(7));
            return builder.toString();
        } else if (length > 7 && length < 11) {
            StringBuilder builder = new StringBuilder();
            builder.append(mobile.substring(0, 2)).append("****").append(mobile.substring(6));
            return builder.toString();
        } else {
            return mobile;
        }
    }
}