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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T02:53:39+00:00 2026-06-01T02:53:39+00:00

I am somewhat familiar to Java, but am using it more now for Android.

  • 0

I am somewhat familiar to Java, but am using it more now for Android.

Anyway, I’m kind of wondering if the only way to instantiate a class variable in Java is to allocate it onto the heap.

For instance:

[C++ Land]
Foo foo;
foo.doSomeAwesomeStuff(9001);

[Java Land]
Foo foo = new Foo();
foo.doSomeAwesomeStuff(9001);

This kind of irks me because there are some things in Java where I just want a temporary variable like a placeholder Matrix, but I don’t want to waste the system’s heap by throwing garbage onto it.

I feel like this might be a call for the android-ndk then, but that feels too much like overkill.

  • 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-01T02:53:40+00:00Added an answer on June 1, 2026 at 2:53 am

    The latter. :\

    The HotSpot JIT compiler automatically tries to do this escape detection to a small extent, when it can detect that a stack allocation is safe, but you cannot control it in general — you can only allocate on the heap.

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

Sidebar

Related Questions

I am somewhat familiar with using configuration in .NET, but I am a little
I am only somewhat familiar with multi-threading in that I've read about it but
I haven't used Rails, but I'm somewhat familiar with it. I'm more familiar with
I'm a newbie to Java, but somewhat familiar to C. I wanted to know
Where I work we're still on .Net 2.0, but I'm somewhat familiar with the
I am somewhat familiar with sorting in Scala using Ordering 's, however I would
I'm somewhat familiar with the various methods of performing non-blocking IO within PHP, but
I'm somewhat familiar with Cocoa, Objective-C and iPhone Development using Xcode. I'm starting to
To get myself a little more familiar with content providers in Android, I'm making
I'm somewhat familiar with displaying simple data via a JMX MBean using older JDKs.

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.