This question already has answers here:
What is the meaning of $ in a variable name?
(2 answers)
Closed 7 years ago.
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?
No, its a legal java identifier part, nothing more, nothing less
Related
This question already has answers here:
Java: Not a statement
(2 answers)
Closed 2 years ago.
I want to know why the following is invalid in Java. Java compiler says that it is not a valid statement.
1+1;
I know the following works.
int i = 1+1;
Please explain why the second one is valid while the first is not. Thanks in advance.
Because you are doing nothing with 1+1. That is not a statement, it's an expression that returns a value that should be stored somewhere, like in the second example you give. If your statements have no effect, they are excluded from the language grammar.
The Java syntax needs the variable to be declared like the following
Class name = value;
You can't create a value without a variable definition and can't create a variable without a name and a class.
This question already has answers here:
While debugging java app what information is shown for a variable in a stack frame [duplicate]
(3 answers)
Closed 4 years ago.
What does 954 mean? I have checked both thread's id and hashcode(), but they don't equal 954.
Also, when using evaluate, there is also a number after #, I think they have the same meaning but still couldn't find out what's the meaning.
Interesting question. I just always took for granted that it is some id that uniquely identifies the object.
Based on that assumption it could for example be the uniqueId() returned by the Java Debugger Interface for an ObjectReference:
https://docs.oracle.com/javase/7/docs/jdk/api/jpda/jdi/
But that is really just an assumption.
This question already has answers here:
What is the role of the data types inside of < > in Java? [duplicate]
(5 answers)
Closed 8 years ago.
I am familiar with using parentheses, as in myMethod(myParameter), in Java and other programming languages, but what do the lesser than < and greater than > signs mean when they are used together in a array name? Is there a special name for them?
Sorry if this is a duplicate, but I don't know how to search for this.
Clarification: I wasn't referring to the role of any specific type inside the symbols, but rather the usage of the <> symbols themselves.
it is java generics, for type safe, and always.using with collections.
i suggest you read the SCJP book, it has a chapter called Generics and Collections, it provides all details you will need, it really helpful. hope it helps.
This question already has answers here:
What is the id=xxx next to variable entries in the Eclipse Debugger
(3 answers)
Closed 9 years ago.
What means (id=40) in Eclipse near variable PacketNr watch info? What this id is used for?
The ID is just an arbitary number assigned by the eclipse debugger. This can be used to determine whether two references are pointing to the same object or not. So two references to the same object should have a same id. This can be a help while debugging.
That is nothing but a unique object-id, eclipse assigns to objects.
It will just help in debugging.
This question already has answers here:
How to convert number to words in java
(31 answers)
Closed 9 years ago.
I'm having a list of Integer from 1 to 100. If I loop through the list, I wanted to make the output as,
"One"
"Two" .....
"Hundred"
Is there any direct method in Java to obtain the above output?
No such method or class has been provided by JDK.
You can use the code mentioned here or here for reference purpose.
switch case are used to meet that requirement: Here
is source code.
Answer of this question described here: How to convert number to words in java
Officially this is not possible or no standard library available by native Java.
Don't duplicate.
There is none in the official Java libraries. However, the International Components for Unicode project has a RuleBasedNumberFormat with those capabilities. It even has a SPELLOUT constant.