| L B (3805) | |
| Satire? I couldn't imagine programming in a language where the code didn't work if you didn't use the proper combination of case in your identifiers. | |
|
|
|
| devonrevenge (891) | |
| kay maybe i shoulda said 'how do i dynamicaly call object methods(?)' from a list thing | |
|
|
|
| L B (3805) | |
| What do you mean, "dynamically call object methods" "from a list"? Can you provide an example scenario or some pseudo code? | |
|
Last edited on
|
|
| devonrevenge (891) | |||
oh sry here:
| |||
|
|
|||
| devonrevenge (891) | |
| anyone? | |
|
|
|
| L B (3805) | |||||
| |||||
|
Last edited on
|
|||||
| devonrevenge (891) | |
| Hur-Javas weird. | |
|
|
|
| L B (3805) | |
| You would do the same in C++, except with pointers. | |
|
|
|
| devonrevenge (891) | |
|
How can i learn to know how to do stuff like that? I love coding but the easy stuff sure bends my head in new ways, i should be much better by now really | |
|
Last edited on
|
|
| devonrevenge (891) | |
|
@LB do you know why i get an error "non static method cannot be referenced from static context?" I solved this before by having said thing in a function, this time its i a function :/ and if i take off extends it says cannot resolve, i guess its inherited nothing, oh dear bended head its late i need sleep and WAY more practice. Im trying to convert the problem into c++ness so i can solve it in mah head | |
|
|
|
| chrisname (6181) | |
| For what line of code does it say that? It sounds like you're trying to call an instance method (a method without the static qualifier, hence a non-static method) via the name of the class (which is a static context) instead of via the name of an object or 'this' (which is an instance/non-static context) | |
|
|
|
| devonrevenge (891) | |
| but its been made dynamically it doesnt have a name :( | |
|
Last edited on
|
|
| L B (3805) | |
| Change "public Recipe getObjectRecipe" to "public static Recipe getObjectRecipe" | |
|
Last edited on
|
|
| devonrevenge (891) | |
|
if i do that then the array list cant be used | |
|
|
|
| devonrevenge (891) | |
| This is why we dont ask java problems in a c++ forum, people arnt as good at it :P | |
|
|
|
| Luc Lieber (985) | |||
Eh! Look at post # 2 in this thread. There're already Java classes for what you're trying to accomplish -- no need to make your own (based on your stated goal). * Don't take it personally, but the standard implementations (minus certain hack-jobs therein) are generally better to use than hand rolled randoms. | |||
|
Last edited on
|
|||
| L B (3805) | |
| @devonrevenge the main method in Java is Static, so everything you want to call from it also has to be Static. Static is an infectious disease, remember? | |
|
|
|
| Luc Lieber (985) | |
|
@LB Static has its (very good) uses. Responsibility is the key. | |
|
|
|
| rapidcoder (736) | |
|
@LB You don't need to use any static besides one in main. @Luc Lieber Static does not belong to the OOP world. While it may have some good use cases - to implement singletons reliably or static constants or static (stateless) utilities methods, it is like goto in structural programming. The better your language is at OOP, the less you need static (Scala dropped static from Java in favor of native support for singletons, Javascript also doesn't have it - programmers are very happy with lack of static). In most cases appearance of static state in your code means designers were lazy and didn't do the architecture well enough. | |
|
Last edited on
|
|
| devonrevenge (891) | |
|
@Luc Lieber, I havn't learnt hash and map stuff yet, guess it was already time, You know i looked at that and thought i would learn it later, Bucky didnt let me in on that secret did he, nooh, he kept it to himself >:( Can you help me finish this hackish hackjob tho, or is it impossible? yeah theres no way i could use the objectlist if eveything starts being static because theres an error. Im not sure if i have perfectly grasped static now :/ | |
|
Last edited on
|
|