/*判断整形数据,先编译,在测试。
javac TestNum.java
编译通过
java TestNum [你要测试的串]
如:java TestNum 8o00
则提示:Your string IS NOT NUMBER!
*/
public final class TestNum
{
public static boolean convertInt(String str)
{
try
{
int n = Integer.parseInt(str);
return true;
}
catch(NumberFormatException e)
{
//e.printStackTrace();
return false;
}
}
public static void main(String[] args)
{
if (args.length != 1)
{
System.out.println("Please input a STRING that you would test!");
}
else
{
String aa=args[0];
boolean bln = convertInt(aa);
if (bln==true)
{
System.out.println("Your string IS NUMBER!");
}
else
{
System.out.println("Your string IS NOT NUMBER!");
}
}
}
}
javac TestNum.java
编译通过
java TestNum [你要测试的串]
如:java TestNum 8o00
则提示:Your string IS NOT NUMBER!
*/
public final class TestNum
{
public static boolean convertInt(String str)
{
try
{
int n = Integer.parseInt(str);
return true;
}
catch(NumberFormatException e)
{
//e.printStackTrace();
return false;
}
}
public static void main(String[] args)
{
if (args.length != 1)
{
System.out.println("Please input a STRING that you would test!");
}
else
{
String aa=args[0];
boolean bln = convertInt(aa);
if (bln==true)
{
System.out.println("Your string IS NUMBER!");
}
else
{
System.out.println("Your string IS NOT NUMBER!");
}
}
}
}
解决方案 »
- ORA-01843: not a valid month
- 关闭窗口的问题
- 500分求,水晶报表导出PDF格式,并保存到本地硬盘
- HTTP请求/响应的消息头可以分批发送吗?
- 在 sql server2005中,找回以前的数据
- xmlns="http://schemas.xmlsoap.org/wsdl/",这是什么意思,我只知道:xmlns:xx=....,
- java如何实现二维码编码和解码!
- 为什么我的.class文件不能在目录下运行?
- 在jbuilder7.0下可以调试运行jsp吗
- 一个数据提交以后和库内数据比对验证的问题。
- 一个基础问题,关于java.lang和java.io
- 路人甲先生:关于这个问题能否说的详细一点?:请教高手,一定送分(70):在jsp或者servlet 中,怎调用linux 的系统命令?(如服务器运行一个servlet ,servlet 可以运行 adduser,mkdir 等linux 的系统命令)
boolean result=false;
for (int i = 0; i < id.length(); i++)
{
if (Character.isDigit(id.charAt(i)) == false)
result = false;
}else result=true;
你为什么这么肯定没有呢?
说说理由行么?
to:redstarstar(红星星)
谢谢你
to:大家
如果你还有其他方法,请回复我好么?谢谢了!