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

  • SEARCH
  • Home
  • 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 9161739
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T14:02:25+00:00 2026-06-17T14:02:25+00:00

This one is straight from Effective java 2. I’m not sure what does this

  • 0

This one is straight from Effective java 2. I’m not sure what does this statement from Item 2 means

The Builder pattern is flexible. A single builder can be used to build
multiple objects. The parameters of the builder can be tweaked between
object creations to vary the objects.

I’m not able to come up with an example to do this.
Please help me understand this with an example.

  • 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-06-17T14:02:26+00:00Added an answer on June 17, 2026 at 2:02 pm

    This blog post provides a good example of builder objects being used by the JavaFX 2 API.

    A single builder can be used to build multiple objects.

    The builder object is responsible for constructing a valid object but The object is not constructed until you call the build() method. This means the same builder can be used multiple times to construct completely different objects.

    Example:

    final TextBuilder builder = TextBuilder.create()
    
    final Text text1 = builder
        .text("Hello World!")
        .x(50).y(50)
        .fill(Color.WHITE)
        .font(MY_DEFAULT_FONT)
        .build();
    
    final Text text2 = builder
        .text("Goodbye World!")
        .x(50).y(100)
        .fill(Color.WHITE)
        .font(MY_DEFAULT_FONT)
        .build();
    

    This can be done as many times as you want to create different objects. Just to re-iterate the point that the object is not created until the build() method is called, consider that you could do the following:

    final Text text1 = TextBuilder.create()
        .text("Hello World!")
        .text("Goodbye World!")
        .text("Hello There!")
        .build();
    

    which would result in the creation of one object, with the text set to ‘Hello There’ as this is the value of the property prior to the build() method being called.

    The parameters of the builder can be tweaked between object creations
    to vary the objects.

    The example below demonstrates this.

    // Set the properties that are common to all objects.
    final TextBuilder builder = TextBuilder.create()
        .x(50)
        .fill(Color.WHITE)
        .font(MY_DEFAULT_FONT);
    
    // Use the builder to construct different objects that have the 
    // properties set above as well as the additional ones set here.
    final Text text1 = builder.text("Hello World!").y(50).build();
    final Text text2 = builder.text("Goodbye World!").y(100).build();
    final Text text3 = builder.text("JavaFX is fun!").y(150).build();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ok this one is might not have a straight forward answer but lets see.
So I know javascript pretty well, but I'm not sure about this one. Tough
Most of this is straight from the hint example. What I'd like to do
This one's a head scratcher. I've created a commented jsFiddle to demonstrate the phenomenon
This one's got me stumped and it's driving me nuts. I have a SiteFinity
This one has me pretty rattled so I thank you in advance for your
This one is a little tricky. Say I have this XmlDocument <Object> <Property1>1</Property1> <Property2>2</Property2>
This one is a little confusing to me. I'm running a LAMP server with
This one is driving me insane, and i can't figure out why it's throwing
This one is a real head scratcher for me... var matches = Regex.Matches(<p>test something<script

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.