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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T14:53:53+00:00 2026-06-18T14:53:53+00:00

When using javax.mail.Message#setRecipeints , I noticed a thing for the first time and wanted

  • 0

When using javax.mail.Message#setRecipeints, I noticed a thing for the first time and wanted to know more about it.

This is my code:

List<InternetAddress> ccRecipients = new ArrayList<InternetAddress>();
// have a valid and working 
// method that fills the list with the data (InternetAddress objects)
message.setRecipients(
         RecipientType.CC, ccRecipients.toArray(new InternetAddress[0]));

Here I am not getting why do we require to create a new InternetAddress array and pass the element at 0th index in the toArray method?

Can anyone explain why do we require this to be done?

I think it has something to do with this special toArray method.

I read the following from the API docs but didn’t get the last part (in bold) :

Like the toArray() method, this method acts as bridge between array-based and collection-based APIs. Further, this method allows precise control over the runtime type of the output array, and may, under certain circumstances, be used to save allocation costs.

How does it save allocation costs?

  • 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-18T14:53:54+00:00Added an answer on June 18, 2026 at 2:53 pm

    toArray() without parameter returns type of Object but toArray(T[] a) returns type of T[]. This is a generic method of List.

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

Sidebar

Related Questions

I have some code that sends emails using javax.mail.Transport class. The code calls the
I'm using the Java Mail API for the first time and I can't get
The Code I'm Using to send a simple mail import javax.mail.*; import javax.mail.internet.*; import
I have a java program that acts as a POP3 client using javax.mail. I
I've been using the org.apache.commons.mail.HtmlEmail class, from apache commons-mail, for some time. Eventually, some
Aside from javax.mail.search.SentDateTerm , what's a good way to get the newest message in
I have this servlet which needs to send mail using Java Mail API, however
I am able to send a mail using javax.mail API. But the problem here
Currently, our application uses a javax.mail to send email, using javax.mail.MailMessage. We set the
I am writing/learning to fetch email using java from an IMAP folder using javax.mail

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.