1. package hanqi;
  2.  
  3. import java.util.Random;
  4. import java.util.Scanner;
  5.  
  6. public class zuoye {
  7.  
  8. public static void main(String[] args) {
  9.  
  10. System.out.println("请输入一个字符串");
  11. Scanner sc =new Scanner(System.in);
  12. String str1 = new String();
  13. str1=sc.nextLine(); //输入一个字符串,用来判断使用
  14.  
  15. char kaitou;
  16. kaitou=str1.charAt(0); //定义 kaitou 为刚才字符串的开头字母
  17.  
  18. System.out.println("请输入一个字符判断是否为字符串的开头");
  19. Scanner a1 =new Scanner(System.in);
  20. String str2 = new String();
  21. str2=a1.nextLine();
  22. char kaitou1;
  23. kaitou1=str2.charAt(0);
  24.  
  25. if(kaitou==kaitou1)
  26. {
  27. System.out.println("输入的是开头");
  28. }
  29. else
  30. {
  31. System.out.println("输入的不是字符串的开头");
  32. }
  33.  
  34. }
  35.  
  36. }

用自己的算法实现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 SDK版本20,Unable to resolve target 'android-20'

    解决方案一 本地缺Android SDK版本20,Unable to resolve target 'android-20' 通过SDK Manager安装一个Android 20. 解决方案二: L ...

  2. mysql查询数据返回touple改为字典的方法

    conn = MySQLdb.connect(host='ip',user='root',passwd='123456',db="dbname",charset="utf ...

  3. strace命令介绍(转)

    原文链接:http://www.cnblogs.com/ggjucheng/archive/2012/01/08/2316692.html 简介 strace常用来跟踪进程执行时的系统调用和所接收的信 ...

  4. Git克隆

    用法1:Git clone <repository> <directory> 将<repository>指向的版本库创建一个克隆到<directory> ...

  5. 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& ...

  6. 拾遗:『ext4 Quota』

    一.关闭selinux [root@ home]# sestatus -v SELinux status: disabled 示例:临时关闭 [root@ home]# setenforce 示例:永 ...

  7. Problem 2136 取糖果---FUOJ (线段树+维护)

    http://acm.fzu.edu.cn/problem.php?pid=2136 题目大意: 给你n个袋子每个袋子里都装有糖果,然后呢你可以每次抽取一个连续的一个区间的袋子,然后带走里面最多糖果数 ...

  8. 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 ...

  9. 获得select下拉框的值

    html -------------------------------------------------------------------------------------- <sele ...

  10. Titanium系列--利用js动态获取当前时间

    动态获取时间: //显示时间 function getDateTime() { var now = new Date(); var year = now.getFullYear(); var mont ...