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 7492061
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T16:13:21+00:00 2026-05-29T16:13:21+00:00

These are from the spring amqp samples on github at https://github.com/SpringSource/spring-amqp-samples.git what type of

  • 0

These are from the spring amqp samples on github at
https://github.com/SpringSource/spring-amqp-samples.git
what type of java constructors are these? are they a short hand for getters and setters?

public class Quote {

    public Quote() {
        this(null, null);
    }

    public Quote(Stock stock, String price) {
        this(stock, price, new Date().getTime());
    }

as oppossed to this one

public class Bicycle {

public Bicycle(int startCadence, int startSpeed, int startGear) {
    gear = startGear;
    cadence = startCadence;
    speed = startSpeed;
}
  • 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-29T16:13:25+00:00Added an answer on May 29, 2026 at 4:13 pm

    These constructors are overloaded to call another constructor using this(...). The first no-arg constructor calls the second with null arguments. The second calls a third constructor (not shown), which must take a Stock, String, and long. This pattern, called constructor chaining, is often used to provide multiple ways of instantiating an object without duplicate code. The constructor with fewer arguments fills in the missing arguments with default values, such as with new Date().getTime(), or else just passes nulls.

    Note that there must be at least one constructor that does not call this(...), and instead provides a call to super(...) followed by the constructor implementation. When neither this(...) nor super(...) are specified on the first line of a constructor, a no-arg call to super() is implied.

    So assuming there isn’t more constructor chaining in the Quote class, the third constructor probably looks like this:

    public Quote(Stock stock, String price, long timeInMillis) {
        //implied call to super() - the default constructor of the Object class
    
        //constructor implementation
        this.stock = stock;
        this.price = price;
        this.timeInMillis = timeInMillis;
    }
    

    Also note that calls to this(...) can still be followed by implementation, though this deviates from the chaining pattern:

    public Quote(Stock stock, String price) {
        this(stock, price, new Date().getTime());
    
        anotherField = extraCalculation(stock);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Spring.NET with Caliburn 2 and getting some exceptions from these frameworks at
Some strange behavior from Spring 3.0 here. package com.service.schedule; import org.springframework.stereotype.Component; @Component(outroJob) public class
Is there an simple way of turning a string from Then go to http:/example.com/
I'm attempting to define an eclipse plugin product that includes bundles from Spring's Enterprise
The following question is related with these technologies: Hibernate 4 or 3 Spring 3.1
Imagine the next architecture: We have Java application over Spring framework (let's call it
I am using Jackson and a ContentNegotiatingViewResolver to return JSON from Spring controllers. When
I have 2 Hibernate classes in a Spring-driven Application like these: @Entity public class
Currently we retrieve a List of objects from the Spring SimpleJdbcTemplate. The first query
I have some model objects I'm using in my Java client application. Later these

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.