【发布时间】:2017-07-05 20:52:32
【问题描述】:
我正在尝试编写一个程序来读取一个单词并打印 if:
以字母 y 结尾。
首尾相同,忽略大小写。
这就是我目前所拥有的,但我很难想出一行代码来检查单个字母或比较第一个和最后一个字母。
if (. . .)
{
System.out.println(word + " ends in a y");
}
if (. . .)
{
System.out.println(word + " starts and ends with the same letter");
}
【问题讨论】:
-
charAt怎么样?
标签: java string if-statement charat