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
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Java Programming - Math.class

  • 04-10-2011 8:38am
    #1
    Registered Users, Registered Users 2 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, Registered Users 2 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, Registered Users 2 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, Registered Users 2 Posts: 9,579 ✭✭✭Webmonkey


    Apologies, too much C++ these days :)


  • Registered Users, Registered Users 2 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