Results 1 to 9 of 9
  1. #1
    lobodelbosque is offline Member
    Join Date
    Nov 2009
    Posts
    12
    Rep Power
    0

    Default Source code of Predefined classes and methods

    Hello,

    How can I see the source code of predefined classes and methods included in Java?

    For example, I'd like to see the currentTimeMills() method, or the String class.

    Thanks.

  2. #2
    dinosoep is offline Senior Member
    Join Date
    Nov 2009
    Posts
    150
    Rep Power
    5

    Default

    go to the folder where your jdk is stored in. there you should find a src.zip file.
    open it and enjoy.
    I learned a lot of it...

  3. #3
    lobodelbosque is offline Member
    Join Date
    Nov 2009
    Posts
    12
    Rep Power
    0

    Default

    Thanks. Thats precisely iI was looking for.
    I got another question, i found the currentTimemillis() method, but there is no code, only a coment:

    public static native long currentTimeMillis();

    /**
    * Returns the current value of the most precise available system
    * timer, in nanoseconds.
    *
    * <p>This method can only be used to measure elapsed time and is
    * not related to any other notion of system or wall-clock time.
    * The value returned represents nanoseconds since some fixed but
    * arbitrary time (perhaps in the future, so values may be
    * negative). This method provides nanosecond precision, but not
    * necessarily nanosecond accuracy. No guarantees are made about
    * how frequently values change. Differences in successive calls
    * that span greater than approximately 292 years (2<sup>63</sup>
    * nanoseconds) will not accurately compute elapsed time due to
    * numerical overflow.
    *
    * <p> For example, to measure how long some code takes to execute:
    * <pre>
    * long startTime = System.nanoTime();
    * // ... the code being measured ...
    * long estimatedTime = System.nanoTime() - startTime;
    * </pre>
    *
    * @return The current value of the system timer, in nanoseconds.
    * @since 1.5
    */

    Where would it be?

  4. #4
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,023
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by lobodelbosque View Post
    Thanks. Thats precisely iI was looking for.
    I got another question, i found the currentTimemillis() method, but there is no code, only a coment:

    public static native long currentTimeMillis();

    Where would it be?
    Did you see the 'native' keyword? That means that the body of that method is written in native code (C or C++). Sun doesn't ship native source code with the Java distribution.

    kind regards,

    Jos

  5. #5
    gcampton Guest

    Default

    Quote Originally Posted by JosAH View Post
    Did you see the 'native' keyword? That means that the body of that method is written in native code (C or C++). Sun doesn't ship native source code with the Java distribution.

    kind regards,

    Jos
    So then is it possible to include precompiled C/C++ code in java programs?

  6. #6
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,023
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by gcampton View Post
    So then is it possible to include precompiled C/C++ code in java programs?
    Yes, read about the JNI (Java Native Interface) mechanism.

    kind regards,

    Jos

  7. #7
    pravallika is offline Member
    Join Date
    Aug 2011
    Posts
    1
    Rep Power
    0

    Default

    hi i need a program for copying a duplicate mobile number in to one new file from two mobile number lists.......some one help me to do this

  8. #8
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,450
    Rep Power
    19

    Default

    1. We're not a code factory.
    2. Don't resurrect the dead.

  9. #9
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    Closing old thread. As tolls said, don't resurrect old threads, ask the question in a new thread.

Similar Threads

  1. Replies: 8
    Last Post: 04-16-2012, 11:00 PM
  2. methods, classes, arrays.. oh my!
    By katalyst in forum New To Java
    Replies: 30
    Last Post: 03-30-2009, 12:57 AM
  3. Classes and Methods help
    By border9 in forum New To Java
    Replies: 5
    Last Post: 01-30-2009, 06:51 PM
  4. Replies: 1
    Last Post: 11-28-2008, 06:27 PM
  5. REGEX - predefined character classes
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 01-10-2008, 10:42 AM

Posting Permissions

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