#What does this output mean ?
1 messages · Page 1 of 1 (latest)
<@&987246399047479336> please have a look, thanks.
While you are waiting for getting help, here are some tips to improve your experience:
If nobody is calling back, that usually means that your question was not well asked and hence nobody feels confident enough answering. Try to use your time to elaborate, provide details, context, more code, examples and maybe some screenshots. With enough info, someone knows the answer for sure.
Don't forget to close your thread using the command </help-thread close:1027500463647621170> when your question has been answered, thanks.
it's not an address, it's ClassName @ hashCode
does it have an actual name ?
And it outputted that because you tried to transform the object into a string and java didn't know what to do
wdym
like does it have an acronym ?
i know it's hard to understand me I'm kinda bad at explaining
so no matter what i do, the output will be a hashcode ?
no
you could try to directly print the name for example
instead of trying to print the whole object
or you could override toString
yeah that's whay i thought using setters and getters
but I'm asking because it was a question on my quiz and i was so frustrated by it
thx btw you're a life saver
what was the question ?
what is the output of the following program.
ah yes, it's ClassName@hashCode
A complete answer would be : "This problem would print out the default implementation of Student class, which would return ClassName@hashCode ie Student@4429dd3e"
thank you so much
@glossy salmon Technically it is called the "identity hash code"
hash code can be overridden
while java isn't a pointer based language, most classes have a defined "identity" associated with them
and that identity stays constant for the object's entire lifetime
you can squint and say "oh its the memory address!" but that isn't true since the jvm will shuffle things around and actual pointers change
right now the only kinds of objects are those with identity that are behind a reference
and primitive objects that do not have an identity and are not behind a reference (like int, double, etc)
in the future that will change, but its a far-ish future
where there will still be identity classes behind references
but also value classes, which are behind references but do not have an identity
and primitive classes, which work exactly like an int