我需要将变量设置为false,如果字符串以“ 1”开头,但是以下代码返回的是真值?我尝试过“苹果”一词。我的代码有问题吗?
String msgName=request.getParameter("msgName");
boolean insideIf=false;
if(msgName.substring(0,1).equals("1"));
{
insideIf=true;
System.out.println("if status :"+msgName.substring(0,1).equals("1"));
} System.out.println("insideIf :"+insideIf);
最佳答案
它是 :-)
如果您有分号,
String msgName=request.getParameter("msgName");
boolean insideIf=false;
if(msgName.substring(0,1).equals("1"))
{
insideIf=true;
System.out.println("if status :"+msgName.substring(0,1).equals("1"));
} System.out.println("insideIf :"+insideIf);