Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Java Programming - Math.class

  • 04-10-2011 09: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