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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T08:35:42+00:00 2026-06-12T08:35:42+00:00

I am really confused by this piece of Java code (a class called Message).

  • 0

I am really confused by this piece of Java code (a class called Message). I think the second constructor is set to initialize data_length with a value, and for this purpose it calls a method named init as you can see.

But what is going on inside init is what makes me bash my head on my desk 😀 What is happening inside this method? Why it is calling itself??

  /**
   * The actual length of the message data. Must be less than or equal to
   * (data.length - base_offset).
   */
  protected int data_length;


  /** Limit no-arg instantiation. */
  protected Message() {
  }

  /**
   * Construct a new message of the given size.
   * 
   * @param data_length
   *          The size of the message to create.
   */
  public Message(int data_length) {
    init(data_length);
  }

  public void init(int data_length) {
    init(new byte[data_length]);
  }

I am converting this code to C#, is it fine if I do just:

public class Message
{    
     //blah blah and more blah

     private int _dataLength;

     public Message(int dataLength)
     {
         _dataLength = dataLength;
     }
 }
  • 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-12T08:35:44+00:00Added an answer on June 12, 2026 at 8:35 am
    public void init(int data_length) {
        init(new byte[data_length]);
    }
    

    It is not calling itself; it’s calling another method named init that takes a byte[] as a parameter.

    The class Message or one of its superclasses contains that other init method – you didn’t show it to us.

    Creating different methods with the same name but different parameter types is called method overloading.

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

Sidebar

Related Questions

I'm really confused right now. This is my piece of code: NSFileManager *manager =
I am really confused with this one. Here's my code class inner { var
I really thought I understood Python variable referencing, so I'm confused why this code
I am really confused about this.I have set the background color of the whole
I'm really confused about this. I'm using the Ruby class below in an automated
there is a question really confused me when i am running this piece of
Ok, I'm really confused by this behaviour in VS2008. This code.. char data[512] =
Really confused with this one. I am selecting an 'a' element by its class
I am getting really confused with this concept: If I want to implement a
I am really confused about how I can do this. I need to get

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.