用自己的算法实现startsWith和endsWith功能。
String str=new String();
str="erty";
Scanner sc= new Scanner(System.in);
System.out.println("请输入内容:");
String str1=sc.nextLine();//定义str1来接受客户输入的内容
int str2=str.indexOf(str1);//定义str2获取客户输入的内容的序号;
if(str2==0)//判断客户输入的内容的索引号是不是等于0,如果等于0则是开头如果不是则不是开头,
{
System.out.println("您输入的是字符串的开头;");
}
else{
System.out.println("您输入的不是字符串的开头;");
}

用自己的算法实现startsWith和endsWith功能。的更多相关文章
- 用自己的算法实现startsWith和endsWith功能
package hanqi; import java.util.Random; import java.util.Scanner; public class zuoye { public static ...
- 1. 用自己的算法实现startsWith和endsWith功能。
package com.xinjian; public class Chazifu { public static void main(String[] args) { String a=" ...
- 【C++实现python字符串函数库】二:字符串匹配函数startswith与endswith
[C++实现python字符串函数库]字符串匹配函数startswith与endswith 这两个函数用于匹配字符串的开头或末尾,判断是否包含另一个字符串,它们返回bool值.startswith() ...
- 在Javascript中使用String.startsWith和endsWith
在Javascript中使用String.startsWith和endsWith 在操作字符串(String)类型的时候,startsWith(anotherString)和endsWith(anot ...
- split与re.split/捕获分组和非捕获分组/startswith和endswith和fnmatch/finditer 笔记
split()对字符串进行划分: >>> a = 'a b c d' >>> a.split(' ') ['a', 'b', 'c', 'd'] 复杂一些可以使用r ...
- python中strip、startswith、endswith
strip(rm)用来删除元素内的空白符: rm对应要删除空白符的元素,当rm为空(strip())时删除所有元素的空白符 startswith.endswith用来查找开头或结尾条件的元素 例子: ...
- Python: 字符串开头或结尾匹配str.startswith(),str.endswith()
问题 需要通过指定的文本模式去检查字符串的开头或者结尾,比如文件名后缀,URLScheme 等等. 解决方案 1.检查字符串开头或结尾的一个简单方法是使用str.startswith() 或者是str ...
- python startswith与endswith
如果你要用python匹配字符串的开头或末尾是否包含一个字符串,就可以用startswith,和endswith比如:content = 'ilovepython'如果字符串content以ilove ...
- python startswith和endswith
startswith判断文本是否以某个或某几个字符开始; endswith判断文本是否以某个或某几个字符结束; text = 'Happy National Day!' print text.star ...
随机推荐
- 数据库SQL server规则的创建、查看、修改和规则的绑定与松绑、删除
用CREATE RULE语句创建规则 创建雇佣日期规则 hire_date_rule CREATE RULE hire_date_rule AS @hire_date>='1980-01-01' ...
- MySQL: LEAVE Statement
https://www.techonthenet.com/mysql/loops/leave.php This MySQL tutorial explains how to use the LEAVE ...
- 2015暑假多校联合---Cake(深搜)
题目链接:HDU 5355 http://acm.split.hdu.edu.cn/showproblem.php?pid=5355 Problem Description There are m s ...
- virtualenvwrapper安装使用
安装 linux和mac下安装 pip install virutalenv virtualenvwrapper windows下安装 pip install virtualenvwrapper-wi ...
- quickstart.sh
#!/bin/bashjava_pid=`ps -ef | grep java | grep 'com.kzhong.huamu.sisyphus.QuickStartServer' | awk '{ ...
- 《Continuous Delivery》 Notes 1: The problem of delivering software
What is "Deployment pipeline"? A deployment pipeline is an automated implementation of you ...
- SQL Server数据类型转换
在SQL Server日常的函数.存储过程和SQL语句中,经常会用到不同数据类型的转换.在SQL Server有两种数据转换类型:一种是显性数据转换:另一种是隐性数据转换.下面分别对这两种数据类型转换 ...
- Aurelia – 模块化,简单,可测试的 JS 框架
Aurelia 是下一代 JavaScript 客户端框架,利用简单的约定来激发你的创造力.凭借其强大的专注于开发经验, Aurelia 可以使您不仅创造惊人的应用程序,同时也享受这个过程.它经过精心 ...
- 携带cookie进行数据请求
前端进行数据请求有:普通的ajax(json)请求,jsop跨域请求,cors跨域请求,fetch请求...PC端这些请求方式中,普通的ajax(json)请求和jsop跨域请求是默认携带cookie ...
- Angularjs 的 ngInfiniteScroll 的使用方法
Angularjs 的 ngInfiniteScroll 的使用方法 一.介绍 ngInfiniteScroll 是一个 AngularJS 的扩展指令,实现了网页的无限滚动的功能,也就是相当于页面滚 ...