📜  android studio 中的字符串长度 - Java 代码示例

📅  最后修改于: 2022-03-11 14:52:07.838000             🧑  作者: Mango

代码示例1
text = et.getText().toString();
if (text == null || text.length() < 3 || text.length > 8) {
    tv.setText("Invalid length, should be from 3 to 8 characters. Please check your code");
} else {
    a = text.substring(0,1);
    b = text.substring(1,2);

    c = text.substring(3,4);
    if (text.length() > 3) {
      d = text.substring(4);
    } else {
         d = null;
    }
}