Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Java Programming - Math.class

Options
  • 04-10-2011 9:38am
    #1
    Registered Users Posts: 7


    I'm just starting into Java programming, having done some programming in Fortran, C and C++ many moons ago. I'm trying to calculate Cos and Sin of an angle but it seems I need 'Math.class' to get it to work. I've found quite a lot of info on different websites about the class and what it does, but nowhere have I found a download link. Can anyone point me in the right direction please.
    Thanks


Comments

  • Registered Users Posts: 9,579 ✭✭✭Webmonkey


    I don't do much Java, well nothing in the past 4 years but have you tried...

    import java.lang.Math.*

    And use static methods such as Math.sin(x);


  • Registered Users Posts: 21,264 ✭✭✭✭Hobbes


    java.lang.* classes are automatically imported into your applications. So you don't need to list them explicitly.

    Here is how to use it:

    http://download.oracle.com/javase/6/docs/api/java/lang/Math.html
    double s = 10.0;
    double answer = Math.sin(s);
    


  • Registered Users Posts: 9,579 ✭✭✭Webmonkey


    Apologies, too much C++ these days :)


  • Registered Users Posts: 7 Mr. Skidoodles


    Thanks for that. I'm left scratching my head now. I had that line in my program and it wouldn't work. Some error relating to Math.class (can't remember exactly, there are so many of them). So I commented it out (// ) and continued. Now after deleting the // it works fine. Today must be a good day for it! Maybe it has Mondays off.
    Thanks again.


Advertisement