Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6118255
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:24:54+00:00 2026-05-23T15:24:54+00:00

I am new to mongodb and as I going through the tutorial for Java

  • 0

I am new to mongodb and as I going through the tutorial for Java & Mongodb. I notice there is put() and append() for BasicDBObject and I took a look at the API, put() inherit and append() is a built-in for BasicDBObject. Does anyone what is the different, such as speed of access? Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T15:24:55+00:00Added an answer on May 23, 2026 at 3:24 pm

    From the BasicDBObject sources:

    public BasicDBObject append( String key , Object val ){
        put( key , val );
        return this;
    }
    

    put() returns the previous value, if applicable. append() calls put() internally and returns the BasicDBObject instance itself. Essentially, append() is a more fluent interface for put(). It allows you to do something like this:

    BasicDBObject o = new BasicDBObject().append("One", 1).append("Two", 2).append("Three", 3);
    

    As far as performance goes, the JVM will supposedly inline methods like append() if they are used frequently enough somewhere. From my experience and quite a bit of profiling, however, that is not always true and you are bound to gain a little bit of speed by using put() directly and saving the JVM the guesswork.

    That said, code readability should always be a priority. Just write your code as you feel comfortable, and benchmark/profile afterwards to find any possible optimizations. Premature optimization is a temptation that should be avoided at all costs…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new to mongoDB. I am using java and mongoDB. I have a
I'm new to MongoDB and I've used RDBMS for years. Anyway, let's say I
I'm new to rails and mongodb, and have a simple form attempting to create
I'm new to Rails development and I'm starting with MongoDB also. I have been
I was following this tutorial : http://pronewb.com/mongodb-as-in-humongous-not-retarded . All was well until the I
I'm relatively new to MongoDB and having trouble with a more advanced upsert. I've
I am new to MongoDB and JDO after mostly doing development with Hibernate in
I am new to MongoDB, but am looking at it to solve this problem:
I am new to MongoDb but have an existing application which would benefit heavily
I'm trying to parse a very large chunk of data into a new MongoDB

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.