How can I convert a double to an int?

Discussion in 'Java' started by Jess K, Aug 23, 2008.

  1. Jess K

    Jess K

    Joined:
    Aug 20, 2008
    Messages:
    1
    How can I convert a double to an int? I'm trying to use the
    Code:
    Double.intValue() 
    method, but I don't know how. I've tried all the ways I can think of, but they don't work:

    Code:
    int x = Double.intValue(); 
    gives the error "non-static method intValue() cannot be referenced from a static context."

    Code:
    int x = arrayDoubleVal.Double.intValue(); 
    gives the error "double value cannot be dereferenced."

    Finally,
    Code:
    int x = Double.intValue(arrayDoubleVal); 
    gives the error "cannot find symbol - method intValue(double)".

    I know, in all likelihood, I've missed something very obvious and I'll kick myself when someone points it out. But I'll just be happy if I can get it to work.

    Thanks in advance.
     
    Jess K, Aug 23, 2008
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sydex
    Replies:
    12
    Views:
    6,646
    Victor Bazarov
    Feb 17, 2005
  2. Schnoffos
    Replies:
    2
    Views:
    1,251
    Martien Verbruggen
    Jun 27, 2003
  3. Hal Styli
    Replies:
    14
    Views:
    1,709
    Old Wolf
    Jan 20, 2004
  4. GRoll21
    Replies:
    9
    Views:
    417
    John Harrison
    Nov 2, 2005
  5. Shriramana Sharma
    Replies:
    8
    Views:
    295
    Gerhard Fiedler
    Jun 18, 2013
Loading...

Share This Page