- eclipse写了一个java程序,运行程序后console不出来,手动打开console可以输入,但输入完之后就什么反应都没了,求助大佬帮忙,谢谢!
注: 把Judgement里的局部参数boolean judgement改成public static boolean judgement = true; 然后再在main中打印judgement就会显示false或true了,到底什么什么原理?还有就是console窗口还是不会自动出现,每次都手动很麻烦,求助!
- 以下是程序代码(运行后没有显示false或true)
public class StringDoubleJudgement
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
String str = input.next();
Judgement(str);
}
public static boolean Judgement(String str)
{
boolean judgement = true;
for(int i = 0; i < str.length(); i++)
{
if(!Character.isDigit(str.charAt(i)))
{
if(str.charAt(i) == '.')
{
if(i == 0 || i == str.length() - 1)
{
judgement = false;
break;
}
}
else
{
judgement = false;
break;
}
}
}
if(str.contains(".") && str.indexOf(".") == str.lastIndexOf("."))
{
judgement = true;
}
else
{
judgement = false;
}
return judgement;
}
}