用自己的算法实现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 ...
随机推荐
- 第三十五章 metrics(3)- codahale-metrics基本使用
<!-- metrics --> <dependency> <groupId>io.dropwizard.metrics</groupId> <a ...
- POSIX信号处理
信号用于通知进程发生了某件事情,可以由一个进程发给另一个进程,也可以由内核发个一个进程. 每个信号都有一个关联的行为,可以通过sigaction函数来设置一个信号的行为,有3种选择: 1.定义一个信号 ...
- HttpURLConnection请求网络数据
//使用线程 new Thread(){ public void run() { try { //先创建出了一 ...
- python学习笔记-Day7
class Province: # 静态字段(类变量/属性) country = '中国' def __init__(self, name): # 普通字段(实例变量/属性) self.name = ...
- 简述UICollectionView 使用
一.介绍 UICollectionView类负责管理数据的有序集合以及以自定义布局的模式来呈现这些数据,它提供了一些常用的表格(table)功能,此外还增加了许多单栏布局.UICollectionVi ...
- XE3随笔5:Format与转义字符
unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, For ...
- GDB的Breakpoint, Watchpoint和Catchpoint
Breakpoint : 设置断点比较直接,在某处停止 Watchpoint : 观察点,即某个变量/表达式发生变化时,停止.可扩展为变量被读/被写/被读or写时都停止 Catchpoint : 在发 ...
- asp控件Repeater运用
双层repeater嵌套 <asp:Repeater ID="rpt_dataRepeatgroup" runat="server" OnItemData ...
- CSS3中的Transition属性详解(贝赛尔曲线)
transition语法: transition : [<'transition-property'> || <'transition-duration'> || <'t ...
- 新机自动创建yum库
#!/bin/bash#for a newsystem to setup auto reposity YUM_DIR=/etc/yum.repos.dMOUNT_DIR=/mntDEV_DIR=&qu ...