how to convert Float to Integer in java?
Float value = 30.0F
how to convert above value to Integer?
Please help me?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Use
Float.intValue():Note that this causes autoboxing, but since you’re planning to create an
Integeranyway, this won’t have any performance impact.Note also that you should pay attention to rounding:
intValue()and anintcast round toward zero. For rounding to the nearest integer, useMath.round(), for rounding down useMath.floor(), for rounding up useMath.ceil(). If you need some other kind of rounding, you need to implement it yourself.