java startswith忽略大小写_在Java中使用startsWith和endsWith时如何忽略大小写?

这是我的代码:

public static void rightSel(Scanner scanner,char t)

{

/*if (!stopping)*/System.out.print(": ");

if (scanner.hasNextLine())

{

String orInput = scanner.nextLine;

if (orInput.equalsIgnoreCase("help")

{

System.out.println("The following commands are available:");

System.out.println(" 'help' : displays this menu");

System.out.println(" 'stop' : stops the program");

System.out.println(" 'topleft' : makes right triangle alligned left and to the top");

System.out.println(" 'topright' : makes right triangle alligned right and to the top");

System.out.println(" 'botright' : makes right triangle alligned right and to the bottom");

System.out.println(" 'botleft' : makes right triangle alligned left and to the bottom");

System.out.println("To continue, enter one of the above commands.");

}//help menu

else if (orInput.equalsIgnoreCase("stop")

{

System.out.println("Stopping the program...");

stopping = true;

}//stop command

else

{

String rawInput = orInput;

String cutInput = rawInput.trim();

if (

我想让用户有一些余地来了解他们如何输入命令,例如:右上角,右上角,右上角,左上角等等.为此,我试图在最后if (,检查是否cutInput以"top"或"up"开头并检查是否cutInput以"left"或"right"结束,所有这些都是不区分大小写的.这是可能吗?

这样做的最终目的是允许用户在一行输入中从三角形的四个方向中选择一个.这是我能想到的最好的方式,但是对于一般的编程我来说还是很新的,可能会使事情变得复杂.如果我是,并且它转向更简单的方式,请告诉我.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值