简体   繁体   中英

Java : Casting from Double to integer

For the method setKVP the parameter required is an Integer value

public void setkVp(int d){
   kVp=d;       
}

But the following code produces Double value, how can i make sure that e.setkVp gives out integer Value instead of Double

s="KVP ";
if (ln.contains(s))
   {
      int i=ln.indexOf("=");
      if (i>0){
         e.setkVp(parse(ln.substring(i+2,ln.length()-3))).intvalue();
      }

parse.. Parses the value of KVP from CSV file.

e.setkVp(parse(ln.substring(i+2,ln.length()-3))).intvalue(); should be formatted as e.setkVp(parse(ln.substring(i+2,ln.length()-3)).intvalue()); else you do intValue() on the return value of setkVp(int) which is void.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM