Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Comparison of C Sharp and Java
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Reference types === In both languages [[Reference (computer science)|references]] are a central concept. All instances of classes are ''by reference''. While not directly evident in the language [[Syntax (programming languages)|syntax]] ''per se'', both languages support the concept of [[weak reference|''weak'' references]]. An instance that is only referenced by weak references is eligible for garbage collection just as if there were no references at all. In both languages this feature is exposed through the associated libraries, even though it is really a core runtime feature. Along with weak references, Java has ''[[soft reference]]s''. They are much like weak references, but the [[Java virtual machine]] (JVM) will not deallocate softly-referenced objects until the memory is needed. {| class="wikitable" style="width:80%;" |- ! style="width:40%;"| Reference types !! style="width:30%;"|Java !! style="width:30%;"|C# |- | [[Garbage collection (computer science)|Garbage collection]] || {{yes}} || {{yes}} |- | [[Weak reference]]s || {{yes}} || {{yes}} |- | Reference queue (interaction with garbage collection) || {{yes}} || {{yes}} |- | [[Soft reference]]s || {{yes}} || {{no}} |- | [[Phantom reference]]s || {{yes}} || {{no}} |- | [[Proxy pattern|Proxy support]] || {{yes}}; proxy generation || {{yes}}; object contexts |}
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)