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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:20:09+00:00 2026-05-24T06:20:09+00:00

I am coding in Android a lot lately, Though I am comfortable in JAVA,

  • 0

I am coding in Android a lot lately, Though I am comfortable in JAVA, but missing some
ideas about core concepts being used there.

I am interested to know whether any performance difference is there between these 2 codes.

First Method:

//Specified as member variable.   
ArrayList <String> myList  = new ArrayList <String>(); 

and using as String temp = myList.get(1);

2nd Method:

ArrayList myList  = new ArrayList(); //Specified as member variable.   

and using

String temp1 = myList.get(1).toString();   

I know its about casting. Does the first method has great advantage over the second,
Most of the time in real coding I have to use second method because arraylist can take different data types, I end up specifying

ArrayList <Object> = new ArrayList <Object>(); 

or more generic way.

  • 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-24T06:20:10+00:00Added an answer on May 24, 2026 at 6:20 am

    In short, there’s no performance difference worth worrying about, if it exists at all. Generic information isn’t stored at runtime anyway, so there’s not really anything else happening to slow things down – and as pointed out by other answers it may even be faster (though even if it hypothetically were slightly slower, I’d still advocate using generics.) It’s probably good to get into the habit of not thinking about performance so much on this level. Readability and code quality are generally much more important than micro-optimisations!

    In short, generics would be the preferred option since they guarantee type safety and make your code cleaner to read.

    In terms of the fact you’re storing completely different object types (i.e. not related from some inheritance hierarchy you’re using) in an arraylist, that’s almost definitely a flaw with your design! I can count the times I’ve done this on one hand, and it was always a temporary bodge.

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

Sidebar

Related Questions

Hey, I spent A LOT of time learning about Android coding and I finally
I am coding an Android client that talks to some web services via XML
I've just started out coding for Android but am struggling to get my head
I am coding in java for android. the issue is how to get mp3
I am a total newbie when it comes to both java and android coding.
Coding i came around to check for the vararg performance of Java. I write
I'v been coming to drawing graphics in Android. There's a lot of sample applications
I've read about phonegap which enables users to write web-based apps for android and
Started coding up a simple android app. Part of it pulls the users last
I changed some code on an android application that was working perfectly fine at

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.