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功能的更多相关文章

  1. 用自己的算法实现startsWith和endsWith功能。

    String str=new String(); str="erty"; Scanner sc= new Scanner(System.in); System.out.printl ...

  2. 1. 用自己的算法实现startsWith和endsWith功能。

    package com.xinjian; public class Chazifu { public static void main(String[] args) { String a=" ...

  3. 【C++实现python字符串函数库】二:字符串匹配函数startswith与endswith

    [C++实现python字符串函数库]字符串匹配函数startswith与endswith 这两个函数用于匹配字符串的开头或末尾,判断是否包含另一个字符串,它们返回bool值.startswith() ...

  4. 在Javascript中使用String.startsWith和endsWith

    在Javascript中使用String.startsWith和endsWith 在操作字符串(String)类型的时候,startsWith(anotherString)和endsWith(anot ...

  5. split与re.split/捕获分组和非捕获分组/startswith和endswith和fnmatch/finditer 笔记

    split()对字符串进行划分: >>> a = 'a b c d' >>> a.split(' ') ['a', 'b', 'c', 'd'] 复杂一些可以使用r ...

  6. python中strip、startswith、endswith

    strip(rm)用来删除元素内的空白符: rm对应要删除空白符的元素,当rm为空(strip())时删除所有元素的空白符 startswith.endswith用来查找开头或结尾条件的元素 例子: ...

  7. Python: 字符串开头或结尾匹配str.startswith(),str.endswith()

    问题 需要通过指定的文本模式去检查字符串的开头或者结尾,比如文件名后缀,URLScheme 等等. 解决方案 1.检查字符串开头或结尾的一个简单方法是使用str.startswith() 或者是str ...

  8. python startswith与endswith

    如果你要用python匹配字符串的开头或末尾是否包含一个字符串,就可以用startswith,和endswith比如:content = 'ilovepython'如果字符串content以ilove ...

  9. python startswith和endswith

    startswith判断文本是否以某个或某几个字符开始; endswith判断文本是否以某个或某几个字符结束; text = 'Happy National Day!' print text.star ...

随机推荐

  1. 第三十五章 metrics(3)- codahale-metrics基本使用

    <!-- metrics --> <dependency> <groupId>io.dropwizard.metrics</groupId> <a ...

  2. POSIX信号处理

    信号用于通知进程发生了某件事情,可以由一个进程发给另一个进程,也可以由内核发个一个进程. 每个信号都有一个关联的行为,可以通过sigaction函数来设置一个信号的行为,有3种选择: 1.定义一个信号 ...

  3. HttpURLConnection请求网络数据

    //使用线程 new Thread(){            public void run() {                try {                    //先创建出了一 ...

  4. python学习笔记-Day7

    class Province: # 静态字段(类变量/属性) country = '中国' def __init__(self, name): # 普通字段(实例变量/属性) self.name = ...

  5. 简述UICollectionView 使用

    一.介绍 UICollectionView类负责管理数据的有序集合以及以自定义布局的模式来呈现这些数据,它提供了一些常用的表格(table)功能,此外还增加了许多单栏布局.UICollectionVi ...

  6. XE3随笔5:Format与转义字符

    unit Unit1; interface uses   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, For ...

  7. GDB的Breakpoint, Watchpoint和Catchpoint

    Breakpoint : 设置断点比较直接,在某处停止 Watchpoint : 观察点,即某个变量/表达式发生变化时,停止.可扩展为变量被读/被写/被读or写时都停止 Catchpoint : 在发 ...

  8. asp控件Repeater运用

    双层repeater嵌套 <asp:Repeater ID="rpt_dataRepeatgroup" runat="server" OnItemData ...

  9. CSS3中的Transition属性详解(贝赛尔曲线)

    transition语法: transition : [<'transition-property'> || <'transition-duration'> || <'t ...

  10. 新机自动创建yum库

    #!/bin/bash#for a newsystem to setup auto reposity YUM_DIR=/etc/yum.repos.dMOUNT_DIR=/mntDEV_DIR=&qu ...