zoukankan      html  css  js  c++  java
  • Java String.endsWith()方法

    Java String.endsWith()方法用法实例教程, 该方法返回一个true,如果参数表示的字符序列是由该对象表示的字符序列的后缀,否则返回false

     
     

    描述

    java.lang.String.endsWith() 方法返回的测试该字符串是否以指定后缀sffix结束

    声明

    以下是声明java.lang.String.endsWith()方法

    public boolean endsWith(String suffix)
    

    参数

    • suffix -- This is the suffix.

    返回值

    该方法返回一个true,如果参数表示的字符序列是由该对象表示的字符序列的后缀,否则返回false.

    异常

    • NA

    实例

    下面的示例演示使用的java.lang.String.endsWith()方法.

    package com.yiibai;
    
    import java.lang.*;
    
    public class StringDemo {
    
      public static void main(String[] args) {
      
        String str = "www.yiibai.com";
        System.out.println(str);
    
        // the end string to be checked
        String endstr1 = ".com";
        String endstr2 = ".org";
    
        // checks that string str ends with given substring
        boolean retval1 = str.endsWith(endstr1);
        boolean retval2 = str.endsWith(endstr2);
    
        // prints true if the string ends with given substring
        System.out.println("ends with " + endstr1 + " ? " + retval1);
        System.out.println("ends with " + endstr2 + " ? " + retval2);
      }
    }
    

    让我们来编译和运行上面的程序,这将产生以下结果:

    www.yiibai.com
    ends with .com ? true
    ends with .org ? false
  • 相关阅读:
    svn 提交时强制注释、不允许指定的文件类型的钩子写法
    开源跨平台网络库(lxnet)
    关于android studio的配置记录
    一般处理程序(ashx)对session处理摘要
    利用反射代替switch -转
    c#+jquery.autocomplete.js
    C#+ajaxupload实现图片上传
    几种常见SQL分页方式效率比较-转
    js页面跳转
    C#编码规范-转
  • 原文地址:https://www.cnblogs.com/lxaic/p/4980550.html
Copyright © 2011-2022 走看看