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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:53:51+00:00 2026-05-28T05:53:51+00:00

I got the unchecked expression error when compiling and found the offending line to

  • 0

I got the unchecked expression error when compiling and found the offending line to be

ArrayList<Integer> items = (ArrayList<Integer>) this.items.clone();

I am trying to perform a deep copy of my object so I am cloning a property of the object and array list in the above manner. How can I fix this warning?

  • I could use @SuppressWarnings("unchecked") but that is just hiding the problem (tho I expect none)
  • If I clone manually by looping through all elements to it will be slower I think

Whats the correct way of doing this?

  • 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-28T05:53:52+00:00Added an answer on May 28, 2026 at 5:53 am

    If your elements are Integers, performing a “deep copy” really isn’t an issue, since there’s no reason why you would need to copy an Integer object. Just use new ArrayList<Integer>(this.items).

    But for reference, neither clone() nor the ArrayList copy constructor will do a deep copy. It’s only because your element types don’t need deep copying that this satisfies your needs.

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

Sidebar

Related Questions

While compiling a program in Java I got this big WARNING warning: [unchecked] unchecked
I'm trying to make an option, to remove all unchecked items in a checked
Got some code that is not mine and its producing this warning atm: iehtmlwin.cpp(264)
I've got a ListView with a custom BaseAdapter. The list items contain CheckBoxes that
Say I've got a mock setup like this: JUnit4Mockery context = new JUnit4Mockery(); MyInterface
This one is pretty crazy: I've got an AppSight recording (for those not familiar,
I'm not entirely sure how I got to this situation but somehow I'm getting
I am deleting contacts from addressbook programmatically. I got error There's already an instance
I've got a single checkbox which i'd like the unchecked value to be 0
This is driving me crazy and must be simple. Basically, I've got a little

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.