Ok Thank u, I got it!
Thank u too for mini correction!
@quark @GoToLoop there is a possibility that you can answer also at my other question in this post?
https://discourse.processing.org/t/neural-network-help/2871
Because I missing something. Of course If you know stuff about Neural Network
Thank you anyway for the appreciated help!
Given that the error message that @Manatee is seeing (âMust qualify the allocation âŚâ) is caused by not using an inner class, Iâm not sure describing less âfudgyâ ways to write code that still wonât work is that useful!
In the example posted earlier with Snake
and Jumble
(which I assume should be Jungle?! ), a static Jumble
class cannot create a Snake
class like that. An inner class has one hidden extra field than a normal class, which is a reference to the enclosing instance - in this case the instance of PApplet
. In effect, whenever you create a Snake
inside PApplet
your call to new Snake()
is translated to something like new Snake(this)
.
Your Jumble class, if it had a reference to a PApplet
, could create a Snake
using -
PApplet applet;
Snake snake = applet.new Snake();
I had to look that syntax up - itâs there but not something you see very often.
In general, just use inner classes and stop fighting with the type system. If you really want static classes, make them all static and pass the PApplet into them. Donât have static classes referring to inner classes or youâll end up in a mess!
Problem solved Dont worry
Ok ok, no problem. I will not use instance method at this point, or I will get with a super messy code!
Anyway is Jumble synonymous of a lot of people/stuff/things
My research shows that the âMust qualify the allocationâŚâ message is created when trying to instantiate an inner class without qualifying it with an object of the outer class.
If the sole reason of making an inner class static is to make it behave like a top-level class then it is fudgy or more accurately, bad programming practice. The code I presented was not meant to be a solution to his code (we donât have it all), it simply shows how to create a true top-level class which he could adapt to his own use.
OK I know this is not technically true but the whole truth can be confusing . For decades it has been good programming practice to name the Java source file after the class. One reason is that It makes it easier to debug large projects.
We donât teach the truth, we teach what the learner can comprehend.
Quark 2018
Alright! However, avoid using absolute verbs like must
, have to
, ought to
.
Go w/ something like should
or need to
instead.
Well, yes if you want it to compile! Although you learn something new every day - never realised it only applied to public classes - and my Java experience is in the decades.
Sorry my mistake, I meant to use the following in my example
public class Population {
in which case it must be in its own file âPopulation.javaâ