Roedy said:
(Methinks the O.P. has some other misconceptions about Java,
too, as witness his use of an `int' to exemplify an object.)
Java makes a lot more sense once you understand the class structure
and the way the byte code machine works. [...]
I guess the choice is whether to learn Java on its own
terms, or to learn it by fitting (forcing?) it into another
already-known framework.
Someone who has written programs in a dozen or fifteen
languages, ranging from assemblers through interpreters to
Fortran and C and Lisp and beyond, may well find a useful
shortcut to understanding Java by studying how Java executes,
noting that different byte codes are used to manipulate
primitives, to invoke static methods, to invoke virtual
methods, and so on. There is nothing wrong, as far as I can
see, with taking such a shortcut.
But Java -- pretty much any full-fledged programming
language, for that matter -- ought also to be understandable
on its own terms, without reference (or without too much
reference) to the implementation techniques that bridge the
gap between the language and the silicon. Putting it perhaps
a little too simplistically, one ought to be able to learn
Java from the JLS without the JVMS. If the learner does not
already have a (fairly extensive) store of prior experience,
appealing to the implementation techniques rather than to Java
itself is not likely to be a shortcut. Rather, it's going to
be more like the trip around Robin Hood's Barn: circuitous,
wearying, and lacking central focus.
It seems to me, reading between the lines of his questions,
that the O.P. is a relative newcomer to programming, and is
unlikely to possess an accumulated store of experience with
which to form useful analogies. I'd therefore encourage him
to approach Java as Java, just as I'd encourage him to approach
Algol as Algol or Scheme as Scheme, and to leave questions of
"Yes, but *how*?" for another day.