Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #39836

Re: How do I dereference a static string

From Arne Vajhøj <arne@vajhoej.dk>
Newsgroups comp.lang.java.programmer
Subject Re: How do I dereference a static string
Date 2022-11-03 20:14 -0400
Organization Aioe.org NNTP Server
Message-ID <tk1lgv$1i5c$1@gioia.aioe.org> (permalink)
References <282053db-e7b9-4f0a-a66c-12f53021fd55n@googlegroups.com> <240bceee-4aa9-4c13-85e7-de1946350bb4n@googlegroups.com>

Show all headers | View raw


On 11/3/2022 3:37 PM, e.d.pro...@gmail.com wrote:
> On Thursday, November 3, 2022 at 1:05:17 PM UTC-4, C.D. Altenburg, Ph.D, wrote:
>> Say I have the string
>>
>> public static string foo = "foo";
>>
>> can I just do
>>
>> foo = null;
>>
>> in order to dereference that string?

> That depends what you mean by dereference. If you want to clear the
> value, sure set to null like that would work. If you mean remove the
> variable from memory, static values are tied to the class, you'd have
> to unload the class.
Note that:

... foo = "foo";
...
foo = null;

Involves two memory locations.

The variable foo that is a reference and a
String object containing "foo".

Arne


Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

How do I dereference a static string "C.D. Altenburg, Ph.D," <cdalten@gmail.com> - 2022-11-03 10:05 -0700
  Re: How do I dereference a static string Andreas Leitgeb <avl@logic.at> - 2022-11-03 17:38 +0000
  Re: How do I dereference a static string "e.d.pro...@gmail.com" <e.d.programmer@gmail.com> - 2022-11-03 12:37 -0700
    Re: How do I dereference a static string Arne Vajhøj <arne@vajhoej.dk> - 2022-11-03 20:14 -0400
  Re: How do I dereference a static string Arne Vajhøj <arne@vajhoej.dk> - 2022-11-03 19:29 -0400

csiph-web