Levi Neuxell wrote:If someone is willing to give an example, please use a real, working program...
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Levi Neuxell wrote:So I can use static functions? I don't know, but it's the only way I could get my program to run properly was by making each variable/method static. (Perhaps tell me an alternative keyword?
Levi Neuxell wrote:
(1): So this creates a foo method that inherits all of the Foo class's variables and such? In which case, the foo method would inherit variable chicken?
(2): What exactly is this doing? Is it creating a sort of pathway to bar() for static methods, variables, and such?
(3): if what I previously said is correct, this should print "mm, good"... is this the case?
(4): or will this be what prints out the statement from the main class?
Sorry if these questions seem kind of dumb, but I'm still pretty new to Java.
In which case, as far as I am concerned, every occurrence of the keyword static, except in public static void main(String[] args) is a mistake.Levi Neuxell wrote: . . . the only way I could get my program to run properly was by making each variable/method static. . . .
Campbell Ritchie wrote:...as far as I am concerned, every occurrence of the keyword static, except in public static void main(String[] args) is a mistake.
I am afraid there are a few things you need to do, and you are not going to like me for this.
1: Ctrl key, A key and del key. Yes. All that code goes in the recycle bin. 2: Power button. Your computer is wasting electricity while it is running, and is actually interfering with your understanding the problem. 3: Pencil, paper and eraser. The latter is by far the most important of the three pieces of hardware
Levi Neuxell wrote:Although the break will most likely be spent asking more questions and trying to find newer, better ways to things...
Edit: On that note about drawing the diagrams and whatnot, I actually love drawing the diagrams. It seems that with programming it's easier for me to draw out the problem then write it, as I end up confusing not only myself but also whomever I'm addressing when my words get jumbled from changing my mind about what I think is going on and such...
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Yes, it is testing the car wash class for problems. It is not about how many objects you are creating or anything, but simply whether the class works. Obviously you will need lots more tests than that, unless your class is really tiny. If your class fails one of the tests, work out why, before you try anything else. If you work out why it fails, you can probably correct it easily; it is usually finding the problem that is difficult.Levi Neuxell wrote: . . .
[1]:This creates 2 new classes, right? Or is it 2 new methods? If it's either, itIt looks more efficient. Is this creating 2 new methods, or 2 instances (I still need to learn what an instance is, so I'll do that on my free time as well)?Never mind, this is a reference that allows a non-static method to be initialized from a static method.
[2]:What exactly do these do?So these are testing each class for problems, correct?. . .
Jeff Verdegan wrote:
Levi Neuxell wrote:
(2): What exactly is this doing? Is it creating a sort of pathway to bar() for static methods, variables, and such?
This is how you call a non-static method. It's a "pathway" yes, but it's not "for static methods." It's simply that if we want to refer to a non-static member (variable or method), then we have to indicate which object's (which instance's) member we're talking about.
Winston Gutkowski wrote:
Levi Neuxell wrote:On that note about drawing the diagrams and whatnot, I actually love drawing the diagrams. It seems that with programming it's easier for me to draw out the problem then write it, as I end up confusing not only myself but also whomever I'm addressing when my words get jumbled from changing my mind about what I think is going on and such...
Well, that's a great start, because it's a lesson that most beginners take a long time to learn.
Just remember the mantra: Whenever you run into problems, StopCoding (←click).
Jeff Verdegan wrote:I can't second that strongly enough. Whatever combination of diagrams, notes, pseudo-code, prose, index cards, post-its, white-board, crayon, clay sculpture, or anything else that works for you and helps you understand the problem and the process to its solution without getting tripped up in the details of the programming language, it's all good. The key is to get your head around the problem and the solution in the abstract first, and then deal with translating it into Java.
As I said earlier, for the time being forget there is such a thing as static.Levi Neuxell wrote: . . . I don't know how to reference a variable without making both it and the method referring to it static. . . . I'm going to create a class called varClass . . .
The only cure for that is hours of television radiation. And this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
|