×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Regular Contributor
    Join Date
    Dec 2004
    Posts
    101

    import java.lang.Math.*;

    I am Using NetBeans 6. when I Create a mobile Application and import the Math class.
    Code:
    import   java.lang.Math.*;
    the ASIN , ACOS, ATAN, ATAN2 are not available

  2. #2
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: import java.lang.Math.*;

    First: I think you are confusing a class import with a static import.

    You can always use a class, without importing, using its fully qualified name. For example:

    Code:
    int biggest = java.lang.Math.max(a, b);
    To avoid using the FQN, you can import a class.

    Code:
    import java.lang.Math;
    
    int biggest = Math.max(a, b);
    Note that you never need to do this for classes in the java.lang package, since they are automatically imported.

    In Java 5 (and later), you can use a static import, and access static members of a class without the class name.

    Code:
    import static java.lang.Math.*;
    
    int biggest = max(a, b);
    This last form cannot be used when developing for mobile, since you must use Java 1.2 source code. You should also avoid it when developing J2SE or J2EE, since it is generally a pretty horrible programming construct.

    So, you don't need to import the Math class. Just use it.

    Second: the CLDC Math class does not have the methods you mention. Check the JavaDocs for a list of available methods. Note that the methods available in the Math class are different between CLDC-1.0 and CLDC-1.1, so you will need to decide which standard you are targetting.

    Graham.

  3. #3
    Regular Contributor
    Join Date
    Dec 2004
    Posts
    101

    Re: import java.lang.Math.*;

    I need to use the Asin - Acos - Atan in CLDC 1.0

    How can I do that.

  4. #4
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: import java.lang.Math.*;

    Your problem is bigger than asin(), acos() and atan(). Since CLDC-1.0 does not support floating point, the Math class contains no trigonometry at all. In CLDC-1.0, Math supports only the int and long functions min(), max() and abs().

    First thing: are you really sure you need to support CLDC-1.0?

    If so, I'd suggest you take a look at this thread.

    If you're able to use CLDC-1.1, take a look at this thread.

    Graham.

Similar Threads

  1. GoogleIt
    By deepika.mangla in forum Symbian
    Replies: 5
    Last Post: 2011-05-28, 11:04
  2. N> help on sending file through bluetooth
    By quardro in forum Mobile Java General
    Replies: 4
    Last Post: 2009-08-06, 18:26
  3. JXME + OSGi for j2me
    By gittu in forum Mobile Java General
    Replies: 13
    Last Post: 2009-03-04, 09:34
  4. bluetooth setting using bluecove
    By amoon108 in forum Bluetooth Technology
    Replies: 0
    Last Post: 2008-10-15, 10:11
  5. problem on running my application
    By rsf in forum Symbian
    Replies: 7
    Last Post: 2007-10-21, 15:56

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×