如何在JAVA控制台输出时判断是否为四位整数

慕妹942279
浏览 2506回答 6
6回答

兮夜丶

用正则表达式判断啊,网上一大堆

XAGT

用try-catch-finally

JackCode

可以使用求余运算符:a%1==0 来判断值是否为整数,返回为boolean值。然后使用Integer的toString().length() 来判断长度。

realwds

可以转换成字符串,然后判断字符个数。在判断第一位是否为零

慕婉清5044891

OVKTIRAJMVRXGPRUQZIRSIAWTVLIKTCFBHQMUWYOQGIYCEVXGWFOFBDPSUJZOIKNPLCKZWLBDFIXTWRAPYBOQGWYKKZPYHQYURTJENDFOIRNQZIXMCYOWFVETHQSIRNCLGVLZIEFAJSHDZDVLTUXFUXZCRKMBKGIENWZOUDYORTJSBKZNIEMHXTCLHDQFHQMVENPLBFHCNCEBXACDXMHEZQYOQGAYUJFNXAIDYHFBQZIEUOXUWZBKGIRACXTPIRTCLHCSOQGJFGWLGCXNJFGCXAPRHJFQYGCRNWLHDZCRNCSVENWAKLURACFVLUVRHJBJEHWMBRAPZKMBKZJYNWGVKSIXTCLUDGCIXMCTPXSIYIHJLUKTVXNIXWMBENQYBKLANPLODGVQMPESBKGILGPLNWSBWZBKMIRUJCZBKHPYHXUPQMORVWMVLOXMISVDAJYIROXENDFXNPMCLAWZPQMVRHEOLVDNCFIEURBKMVKAWZIESOWEUWSIDZHQGVQMIXTVEAPYWFOEGPLBRAQLUDSVXTVEUQLUWTJLNJGIRFUDNIFOXTIWMVLHJGBKGWZJGBLAJGPYHXKSVRORNPSBRMPRHDZPXUQFIQZIYHQGWFUUPSHENWFPFBQZBEGCZVYCSWFAQYIRNKTJEGISMISBROXODYBDNDNWZPWFNXFUKNCTDDSIEADZBYPYKSCJMPRAQAJRNPGPZHRZDZKMCWFISBKAPRBYHETCZBLBSHVLBWGIYVEJSUXTWSCQZPTPYVKTDGJYBZCXUOENWZPZWYHQOJHCRBRAWLURHWSILZZIXAJFVRGPRKAILBKGWYJZNNDMORUDTCFPYUKZKTIYCMKTCMIYIKNDMZOENXUXADGPQZHXAQFCRAD

兮夜丶

00 0 0

kuun993

大于999小于10000不就行了么
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java