There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
brent carter wrote:part of the trouble I am having is that I know so little so it is difficult for me to articulate my questions. basically what I didn't know about and just found out researching was making a variable static vs non-static. Form my understanding when I make a variable for ex: "static int charpick" at the class level, once it gets defined in that class it stays that definition unless it is changed somewhere else. Unchanged, it retains its current value even when called from another class. Is this accurate?
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Unchanged, it retains its current value even when called from another class. Is this accurate?
Costs matter. Justice lies in processes not outcomes. Crime is caused by criminals.
Thomas Kennedy wrote:
When the jvm loads up it looks through the classpath for everything and anything marked static
. When it finds something it loads up one instance of the class where that static thing -- a method, a constant, whatever -- is found.
It puts that instance in a special roped-off area you don't have direct access to.
It is to this instance that the compiler directs all references to Static Thing.
brent carter wrote:One last quick question on this thread. Is there every a problem of having too many classes? Is it good coding procedure to try and limit the class number to some degree or is it good to have many classes that do very specific things?
brent carter wrote:I think the mistake I've been making this whole time is mistaking local instances with classes.
brent carter wrote:thanks Jeff for the great post. This makes things a lot clearer. So just to make sure I understand, if i have something in a class like:
public void console(){
String name
the string name exists only in the method console. Once the method ends name goes away.
I am Arthur, King of the Britons. And this is a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
|