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. android 编译错误 com/android/dx/command/dexer/Main : Unsupported major.minor version 52.0

    解决方案一: JDK版本不一致造成的,指的是高版本的JDK编译的class不能放在低版本的JDK上运行. 如果是Version 52,就表示JDK8编译的class不能运行在JDK7上,所以需要在本地 ...

  2. mysql术语解释

    数据库(database): 数据表的集合: 数据表 (table):数据的矩阵: 列(column): 相同属性的数据的集合: 行(row): 一个对象的各种属性数据的集合: 冗余():一个字段在多 ...

  3. JavaScript求最大数最小数

    <!DOCTYPE html><html><head lang="en"> <meta charset="UTF-8" ...

  4. 基于TP框架的ThinkCMF,控制器display方法源码分析

    昨天在写代码的时候,看见写了无数次的模版渲染方法:$this->display(),突然很想弄清楚它是如何实现的. 今天不忙,就分析了一下. class TestController exten ...

  5. iOS.ReactNative-4-react-native-command-line-tool

    Command line tool: react-native 1. react-native 是一个命令行工具 1.1 react-native简介 运行以下命令: ls -lt `which re ...

  6. 对比poj3050

    #include <stdio.h> const int MAXN = 10; const int dir[4][2] = { {-1, 0}, {1, 0}, {0, -1}, {0, ...

  7. cocos2d-x源码分析(1)

    class CC_DLL CCCopying { public: virtual CCObject* copyWithZone(CCZone* pZone); }; class CC_DLL CCZo ...

  8. C++中new和malloc的区别

    原文:http://blog.163.com/ji_wei8888/blog/static/4868044620117361747282/ 1.new 是c++中的操作符,malloc是c 中的一个函 ...

  9. js中判断输入的数字是否是数值类型

    p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 30.0px Consolas; color: #2b7ec3 } p.p2 { margin: 0.0px ...

  10. 【洛谷P3258】松鼠的新家

    很好的一道题 LCA+树上前缀和 sum数组是前缀和数组, 分类讨论一下, 1.访问到一个点p1,若下一个点p2需要往儿子下面找的话,那么lca就是这个点p1,则sum[p1]--; sum[p2]+ ...