Is there any method or quick way to check whether a number is an Integer (belongs to Z field) in Java?
I thought of maybe subtracting it from the rounded number, but I didn't find any method that will help me with this.
Where should I check? Integer Api?
With Z I assume you mean Integers , i.e 3,-5,77 not 3.14, 4.02 etc.
A regular expression may help:
Quick and dirty...
edit: This is assuming x is already in some other numeric form. If you're dealing with strings, look into
Integer.parseInt
.// in C language.. but the algo is same