Originally posted by Vonique Leary:
... Can you keep recreating the same object over and over??? ...
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Not all of these are assigned instances of Mix4.
To me it looks like objects are being created inside the same class that defines it. In other places in the book it says that you need to classes to create an object. One to define it and another one with a main method to instantiate it. I think this is where I might be going wrong.
Originally posted by Vonique Leary:
To me it looks like objects are being created inside the same class that defines it. In other places in the book it says that you need to classes to create an object. One to define it and another one with a main method to instantiate it. I think this is where I might be going wrong.
In the above sentence I meant to say In other places in the book it says that you need two classes to create an object.
Can anyone suggest a really good beginner's book? I've read the list on this website, but if anyone has actual experience with it, I'd like to know.
Thanks for any help. Von
Originally posted by Vonique Leary:
So, in other words, the main class is really not part of the Mix4 class and is therefore able to instantiate objects of Mix4? Okay, that's starting to make more sense, then.
But the other thing that confuses me is: what is actually in Mix4? As far as I can see this is the only thing that comprises Mix4:
Is MaybeNew() part of main or part of Mix4?
Since the main method is static and is the first method called during execution, it doesn't have any object of the class it belongs and hence is free to create an object of the same class to call other non-static methods.
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Originally posted by Vonique Leary:
... In other places in the book it says that you need [two] classes to create an object. One to define it and another one with a main method to instantiate it. I think this is where I might be going wrong...
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Originally posted by Vonique Leary:
... Doesn't this:
mean they are all of type Mix4's?
I can see that some are being created inside main and some inside MaybeNew but I can't see which are null...
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
If there wasn't a main method, could Mix4 create more Mix4's, like say within a method right in the same class of Mix4?
Originally posted by Vonique Leary:
...Mix4 m4 = new Mix4(); // Doesn't this keep creating the
//same object over and over again?...
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Originally posted by Vonique Leary:
So, if m4 is destroyed after the local method runs, what happens to what's done with it inside the code:
I assume that since counter is an instance variable, it does not get destroyed after the method has run? Is that the reason m4 has to keep getting recreated, so that the counter variable can be incremented each time?
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
A thousand lemmings can't be wrong...?