package lianxi;
import java.util.*;
public class kaishihejiewei {
public static void main(String[] args) {
System.out.print("请输入字符:");
Scanner str = new Scanner(System.in);
String a = str.next();
String b = "abcdefghijklmn";
if (a.length() > b.length()) {
System.out.println("输入的字符长度有误");
} else {
if (b.indexOf(a) == 0) {
System.out.println("输入的字符是字符串的开头");
} else {
System.out.println("输入的字符不是字符串的开头");
}
if (a.equals(b.substring(b.length() - a.length()))) {
System.out.println("输入的字符是字符串的结尾");
} else {
System.out.println("输入的字符不是字符串的结尾");
}
}
}
}
![](https://images2015.cnblogs.com/blog/917851/201605/917851-20160513211044359-866530637.png)
![](https://images2015.cnblogs.com/blog/917851/201605/917851-20160513211057937-436806526.png)
![](https://images2015.cnblogs.com/blog/917851/201605/917851-20160513211107515-1177365452.png)
![](https://images2015.cnblogs.com/blog/917851/201605/917851-20160514083647390-257532558.png)
![](https://images2015.cnblogs.com/blog/917851/201605/917851-20160513211130234-1361507181.png)