用自己的算法实现startsWith和endsWith功能
- package hanqi;
- import java.util.Random;
- import java.util.Scanner;
- public class zuoye {
- public static void main(String[] args) {
- System.out.println("请输入一个字符串");
- Scanner sc =new Scanner(System.in);
- String str1 = new String();
- str1=sc.nextLine(); //输入一个字符串,用来判断使用
- char kaitou;
- kaitou=str1.charAt(0); //定义 kaitou 为刚才字符串的开头字母
- System.out.println("请输入一个字符判断是否为字符串的开头");
- Scanner a1 =new Scanner(System.in);
- String str2 = new String();
- str2=a1.nextLine();
- char kaitou1;
- kaitou1=str2.charAt(0);
- if(kaitou==kaitou1)
- {
- System.out.println("输入的是开头");
- }
- else
- {
- System.out.println("输入的不是字符串的开头");
- }
- }
- }
用自己的算法实现startsWith和endsWith功能的更多相关文章
- 用自己的算法实现startsWith和endsWith功能。
String str=new String(); str="erty"; Scanner sc= new Scanner(System.in); System.out.printl ...
- 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 ...
随机推荐
- 本地缺Android SDK版本20,Unable to resolve target 'android-20'
解决方案一 本地缺Android SDK版本20,Unable to resolve target 'android-20' 通过SDK Manager安装一个Android 20. 解决方案二: L ...
- mysql查询数据返回touple改为字典的方法
conn = MySQLdb.connect(host='ip',user='root',passwd='123456',db="dbname",charset="utf ...
- strace命令介绍(转)
原文链接:http://www.cnblogs.com/ggjucheng/archive/2012/01/08/2316692.html 简介 strace常用来跟踪进程执行时的系统调用和所接收的信 ...
- Git克隆
用法1:Git clone <repository> <directory> 将<repository>指向的版本库创建一个克隆到<directory> ...
- POJ 1742 Coins DP 01背包
dp[i][j]表示前i种硬币中取总价值为j时第i种硬币最多剩下多少个,-1表示无法到达该状态. a.当dp[i-1][j]>=0时,dp[i][j]=ci; b.当j-ai>=0& ...
- 拾遗:『ext4 Quota』
一.关闭selinux [root@ home]# sestatus -v SELinux status: disabled 示例:临时关闭 [root@ home]# setenforce 示例:永 ...
- Problem 2136 取糖果---FUOJ (线段树+维护)
http://acm.fzu.edu.cn/problem.php?pid=2136 题目大意: 给你n个袋子每个袋子里都装有糖果,然后呢你可以每次抽取一个连续的一个区间的袋子,然后带走里面最多糖果数 ...
- hdu 1086 You can Solve a Geometry Problem too
You can Solve a Geometry Problem too Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/3 ...
- 获得select下拉框的值
html -------------------------------------------------------------------------------------- <sele ...
- Titanium系列--利用js动态获取当前时间
动态获取时间: //显示时间 function getDateTime() { var now = new Date(); var year = now.getFullYear(); var mont ...