3 Replies - 558 Views - Last Post: 14 November 2013 - 04:25 PM Rate Topic: -----

#1 conure  Icon User is offline

  • D.I.C Head

Reputation: 17
  • View blog
  • Posts: 99
  • Joined: 03-August 12

built in methods, standard libraries - newbie question

Posted 14 November 2013 - 08:39 AM

Hey everyone,

I'm trying to get a better understanding of a few features in Java that I regularly use but don't really understand.

My first question is: Is the standard library a list of built in classes? I'm a bit confused about this definition.

My second question is, when I invoke a method like parseInt, what actually is parseInt? Is it a standard class of written code like a class I might write, which is pre-written because it is useful and commonly used? I think what I mean is, is it literally a page of code class with an internal method which is called with the parseInt method? I'm not specifically talking about parseInt, but any method I call which I haven't written myself.

Hope I've made sense here!

Thanks.

Is This A Good Question/Topic? 0
  • +

Replies To: built in methods, standard libraries - newbie question

#2 g00se  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3463
  • View blog
  • Posts: 15,673
  • Joined: 20-September 08

Re: built in methods, standard libraries - newbie question

Posted 14 November 2013 - 10:05 AM

The simple answer is ... yes to all ;)/>

You're basically accessing the common classes of the runtime, usually in rt.jar of the distribution. You'll see the standard classes documented in the api Javadoc:

http://docs.oracle.c.../api/index.html

This post has been edited by g00se: 14 November 2013 - 10:06 AM
Reason for edit:: typo

Was This Post Helpful? 1
  • +
  • -

#3 jon.kiparsky  Icon User is online

  • Chinga la migra
  • member icon


Reputation: 10720
  • View blog
  • Posts: 18,353
  • Joined: 19-March 11

Re: built in methods, standard libraries - newbie question

Posted 14 November 2013 - 01:18 PM

Quote

Is the standard library a list of built in classes?


Yes, assuming we clarify what's meant by "built in". The standard distribution includes the java.* packages: you can't install java without installing java.lang and java.util and so forth. So in that sense they're built in to any java install you're going to come across.

However, you can also think of a "core language" of java: this would be the language as defined in the Java Language Spec. This includes almost no classes - possibly just the ones in java.lang, but I wouldn't want to swear to it. Since the JLS is the sole definition of what it means for something to be java, you could say that the rest of the standard library is not really "built in" in the way that java.lang.String is built in. What I mean by this is, if you left out java.util.HashSet, java would still be java. If you left out java.lang.String, you wouldn't have java anymore.

But of course this is nitpicking: the real answer is yes, this is a list of built-in classes that you get for free with Java.
And it's worth the trouble to learn your way around these. Not only does it save you time to use the library code, but you're using extremely well tested code that's probably going to run a lot faster than anything you write to do the same. These are good wheels to reinvent if you want to learn something from the process, but they're excellent wheels, and they're the ones you should put on your bike if you really want to take it around the block.

Quote

when I invoke a method like parseInt, what actually is parseInt? Is it a standard class of written code like a class I might write, which is pre-written because it is useful and commonly used? I think what I mean is, is it literally a page of code class with an internal method which is called with the parseInt method?


Yes :)/>

This post has been edited by jon.kiparsky: 14 November 2013 - 01:21 PM

Was This Post Helpful? 0
  • +
  • -

#4 conure  Icon User is offline

  • D.I.C Head

Reputation: 17
  • View blog
  • Posts: 99
  • Joined: 03-August 12

Re: built in methods, standard libraries - newbie question

Posted 14 November 2013 - 04:25 PM

Thank you both for your (as always!) very detailed replies. I'd never really understood the inbuilt classes before but now I can see they're literally just scripts of code!

Thank you again:)

This post has been edited by andrewsw: 14 November 2013 - 04:41 PM
Reason for edit:: Removed large quote

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1