Will Java ever support reference variables?
-
I know arrays and objects are pass-by-reference. but i'm really referring to primitive data types. I've noticed that when it comes to data structure and memory management, the vast majority switches out to C++. Will Java ever support pointers, you think? I'd also like to know exactly how an object it removed off stack after it has nothing pointing to it since Java is a garbage-collection language.
-
Answer:
You have the primitive wrapper classes like Integer you can use on the rare occasions you need to treat a primitive as an object. It was an efficiency sacrifice the designers made. Pointers? No, and there's not much point. Pointers lead to some hairy memory management issues. Java objects are craeted on the heap, not the stack. Every time a new reference to an object is created, its reference count is incremented. When the reference's fall out of scope, the count is decremented. When the count hits zero, the object is made available for garbage collection. So: Object obj=new Object(); Object obja=obj; Object objb=obj; sets the reference count for the underlying object to 3.
Fadi at Yahoo! Answers Visit the source
Other answers
Never. Java prides itself on ignoring references altogether by making them part of the code. The downside to that is that primitives will always be pass-by-value.
Darnental
NO. Java is a porly designed language. and actually i dont even consider it a "language". i consider it a scripting language. It requires a RUNTIME! javascript and vbscript require runtimes too. whats the difference :P
Andrew Krieg
Related Q & A:
- Is Java pass by value or pass by reference?Best solution by Stack Overflow
- What is a parameterized reference in Java?Best solution by kodejava.org
- Will Pluto and Neptune ever collide?Best solution by Yahoo! Answers
- How hard will AP computer science if I have no past knowledge of programing or Java?Best solution by Yahoo! Answers
- Will my income support change?Best solution by www.gov.uk
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.