Snippets

Discussion in 'Java' started by bob smith, Sep 5, 2012.

  1. bob smith

    bob smith Guest

    Is there a good place where you can get lots of "Snippets" of Java code (like for Eclipse)?

    I'm looking for snippets like for "starting a thread."
     
    bob smith, Sep 5, 2012
    #1
    1. Advertising

  2. bob smith

    Eric Sosman Guest

    On 9/5/2012 11:17 AM, bob smith wrote:
    > Is there a good place where you can get lots of "Snippets" of Java code (like for Eclipse)?
    >
    > I'm looking for snippets like for "starting a thread."


    Don't know about the general matter, but for the specific
    question see

    <http://docs.oracle.com/javase/tutorial/essential/concurrency/runthread.html>


    --
    Eric Sosman
    d
    "The speed at which the system fails is usually not important."
     
    Eric Sosman, Sep 5, 2012
    #2
    1. Advertising

  3. bob smith

    Daniel Pitts Guest

    On 9/5/12 8:17 AM, bob smith wrote:
    > Is there a good place where you can get lots of "Snippets" of Java code (like for Eclipse)?
    >
    > I'm looking for snippets like for "starting a thread."
    >

    Google is a good place to search for snippets. For your example,
    <http://lmgtfy.com/?q=starting+a+thread+in+java>

    Though this is a terrible way to program, because people often don't
    fully understand what the snippet does (especially if this is the only
    way they program). Often times there are multiple ways to approach
    something, each with different trade-offs and implications. Simply
    copying the first snippet that seems to work will eventually lead to
    disaster. This is true with any language, not just Java.

    I suggest instead learning how to actually program in Java. Read
    tutorials, buy books, ask smart questions.

    If you're interested in threading specifically, a must-read is "Java
    Concurrency in Practice"

    <http://www.amazon.com/dp/0321349601?tag=virtuinfinnet-20&camp=14573&creative=327641&linkCode=as1&creativeASIN=0321349601&adid=070QHH97QBDPJ8X254PX>

    Yes, buying from that link gives me money, but you can search for the
    book on Google if you feel they deserve the money more than I do :)

    They have plenty of "snippets" in that book too, BTW.

    Anyway, good luck,
    Daniel.
     
    Daniel Pitts, Sep 5, 2012
    #3
  4. bob smith

    Lew Guest

    Leif Roar Moldskred wrote:
    > bob smith wrote:
    > > Is there a good place where you can get lots of "Snippets" of Java code (like for Eclipse)?


    "like for Eclipse"? What do you mean?

    > There _were_ they O'Reilly Cookbooks for Java, but those are pretty
    > old and rather dated now.


    Just about every article on IBM's Developerworks for Java site.
    https://www.ibm.com/developerworks/java/

    --
    Lew
     
    Lew, Sep 5, 2012
    #4
  5. bob smith

    Roedy Green Guest

    On Wed, 5 Sep 2012 08:17:02 -0700 (PDT), bob smith
    <> wrote, quoted or indirectly quoted someone
    who said :

    >Is there a good place where you can get lots of "Snippets" of Java code (like for Eclipse)?
    >
    >I'm looking for snippets like for "starting a thread."


    If you look up the name of a component or collection in the Java
    glossary http://mindprod.com/jgloss/jgloss.html, there will be a self
    contained compilable example to demonstrate the basic features of its
    use.

    You can look up things like JDBC to see how to open various databases,
    SQL to do the basic operations, enum for how to do things with
    enums...
    --
    Roedy Green Canadian Mind Products http://mindprod.com
    A new scientific truth does not triumph by convincing its opponents and making them see the light,
    but rather because its opponents eventually die, and a new generation grows up that is familiar with it.
    ~ Max Planck 1858-04-23 1947-10-04
     
    Roedy Green, Sep 7, 2012
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. - Steve -

    Reusing Code Snippets

    - Steve -, Sep 30, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    430
    Greg Burns
    Oct 1, 2004
  2. Pat

    Where are my Code Snippets?

    Pat, Apr 20, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    398
    Simon Harris
    Apr 23, 2005
  3. Steve Franks
    Replies:
    2
    Views:
    365
    Juan T. Llibre
    Sep 11, 2005
  4. Edwin Knoppert
    Replies:
    0
    Views:
    373
    Edwin Knoppert
    Nov 30, 2005
  5. Committing Code Snippets

    , Dec 17, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    352
Loading...

Share This Page