• Post Reply Bookmark Topic Watch Topic
  • New Topic

Source code for library classes/methods?  RSS feed

 
Christiaan Thamm
Ranch Hand
Posts: 34
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey guys

Im a beginner doing some random programs here and there and finding the java libary very usefull. There is one thing though, where can I find the source code for the methods I use. Like for example im trying to find how the String Class Replace method was done, but I cant find this anywhere. Doing a search only takes you to example that used it

Thanks
 
Junilu Lacar
Sheriff
Posts: 11494
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you try searching for "java source code"?
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Christiaan Thamm wrote:where can I find the source code for the methods I use. Like for example im trying to find how the String Class Replace method was done...

There's nothing particularly wrong with looking at source code to "find out how the experts do it", but do be very careful that you don't fall into the trap of writing programs that rely on (or assume) a particular implementation.

There's a reason the designer hid the source from you: they might want to change it later.

Also: while you can get source for most of the Java foundation classes, you may not be able to get it for 3rd party libraries or jars.

Winston
 
Jayesh A Lalwani
Rancher
Posts: 2762
32
Eclipse IDE Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One thing I have found useful with Maven is that it makes it easy to download the source from 3rd party open source libraries for you. Also, if you use m2eclipse to open maven projects from Eclipse, Eclipse automatically downloads the source of a class when you open a class. It makes solving problems a breeze. Most of the problems with 3rd party libraries is either that the programmer didn't understand the API, or the API wasn't documented well. Being able to debug through 3rd party libraries seamlessly through the IDE makes solving problems so much easier.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!