0

I've recently inherited an old Java application. Almost every variable has a $ at the end of it such as: String log$ = "job: " + task$;

As I understand it, using a $ in a variable violates Java's naming conventions. This is not a convention that's been used in other applications here either. When I asked around to find out why the application was written this way, I was told that the original developer's explanation was that the $ signals for immediate garbage collection as soon as the variable is out of scope.

I've been unable to find any sources that back up this explanation. Does anyone know if using a $ at the end of a variable has any special significance?

aillia
  • 11
  • 3
  • 1
    Please readl through all the answers in the post, not only the accepted answer. – Luiggi Mendoza May 13 '15 at 19:40
  • A dollar sign isn't very common in Java. It is in javascript, when using jQuery especially and when using php. – Max May 13 '15 at 19:41
  • 1
    There are many persistent false beliefs about Java. This is not one of them. I've been using Java for over fifteen years, and I've never heard of such a belief about variable names. I wonder if it comes from some other language, or if the original developer was just insane, as original developers so often are. – Kevin Krumwiede May 13 '15 at 19:46
  • I read through all the answers in that post. I posted my question because the explanation I was given was that the $ at the END of the variable name was significant. That wasn't specifically addressed in the post you referred to, and I wanted a straight answer before I refactored any code. – aillia May 13 '15 at 19:46
  • Yeah, this question should not have been marked as a duplicate. It's more specific than the linked question. – Kevin Krumwiede May 13 '15 at 19:48
  • 1
    @aillia it wasn't *addressed* because **there's no special meaning** and some of the answers cite the Java Language Specification. If it's not dictated there, then there's no place where you can find a proof of what you're stating. – Luiggi Mendoza May 13 '15 at 19:54
  • @KevinKrumwiede it's a duplicate. The answer can be deduced from the posts there. – Luiggi Mendoza May 13 '15 at 19:54

1 Answers1

1

No, its a legal java identifier part, nothing more, nothing less

Blank Chisui
  • 1,043
  • 10
  • 25