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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T04:12:14+00:00 2026-05-30T04:12:14+00:00

new AlertDialog.Builder(this) .setMessage(mymessage) .setTitle(title) .setCancelable(true) .setNeutralButton(android.R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int

  • 0
new AlertDialog.Builder(this)
  .setMessage(mymessage)
  .setTitle(title)
  .setCancelable(true)
  .setNeutralButton(android.R.string.cancel,
     new DialogInterface.OnClickListener() {
     public void onClick(DialogInterface dialog, int whichButton){}
     })
  .show();

Hi, could someone explain what this java language feature is called, to be able to call methods without directly specifying the object before the ‘.’ ?

I would like to read more about how to use this…

and does it only work with “new” or can I use existing objects with this syntax?

  • 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-30T04:12:15+00:00Added an answer on May 30, 2026 at 4:12 am

    The line of code is terminated by the semicolon. What you have there is (formatting-aside) identical to:

    new AlertDialog.Builder(this).setMessage(mymessage).setTitle(title).setCancelable(true).setNeutralButton(android.R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton){}}).show();
    

    I think you’ll agree that the linebreaks make it more readable!

    Now, each one of those methods in the chain is implemented as returning this as a useful “side effect” (in the intent sense, rather than functional sense) – this means that myBuilder.setMessage(myMessage) returns the modified myBuilder, which you’re then free to use .setTitle(title) on, et cetera.

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

Sidebar

Related Questions

@Override protected void onStop() { super.onStop(); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage(Test message) .setCancelable(true)
I currently have this: Builder yesandno = new AlertDialog.Builder(this); yesandno.setTitle(QuickResponse); yesandno.setMessage(message); yesandno.setPositiveButton(YES, null); yesandno.setNegativeButton(NO,
I'm very new on Android development. I have this: AlertDialog.Builder builder = new AlertDialog.Builder(this);
I got this dialog snipet: String message=This will be my message; AlertDialog.Builder alt_bld =
My code: package com.example.linkingpage; import android.app.Activity; import android.app.AlertDialog; import android.app.Dialog; import android.content.DialogInterface; import android.content.Intent;
New to javascript/jquery and having a hard time with using this or $(this) to
new Date(05-MAY-09 03.55.50) is any thing wrong with this ? i am getting illegalArgumentException
try{ File f = new File(/data/cizip.zip); if(f.exists()){ ZipFile zf = new ZipFile(f); //this always
I have this below code access the ListView item value into string and display
I'm very new to Android so I've been working primarily with information from the

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.