contains()方法

更新时间:2023-05-10 18:14:12 阅读: 评论:0

contains()⽅法描述
java.ains()⽅法返回true,当且仅当此字符串包含指定的char值序列
声明
以下是声明java.ains()⽅法
public boolean contains(CharSequence s)
参数
s-- This is the quence to arch for.
返回值
如果此字符串包含,此⽅法返回true,否则返回fal。
异常
-- if s is null.
实例
下⾯的例⼦说明了如何使⽤java.ains()⽅法
1 2 3 4 5 6 7 8 9 10 11 12 13 14    package com.yiibai;
import java.lang.*;
public class StringDemo {
public static void main(String[] args) {
String str1 = "tutorials point", str2 = "";
CharSequence cs1 = "int";
// string contains the specified quence of char values
boolean retval = ains(cs1);
System.out.println("Method returns : "+ retval);
/
/ string does not contain the specified quence of char value                  retval = ains("_");
System.out.println("Methods returns: "+ retval);
}
}
让我们来编译和运⾏上⾯的程序,这将产⽣以下结果:Method returns : true
Methods returns: fal

本文发布于:2023-05-10 18:14:12,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/82/574728.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:指定   字符串   包含   返回   序列
相关文章
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图