Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
What exactly do you mean when you say that this won't work?
Where is your class? Where is your main method?
Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
Okay, and what exactly do you mean when you say this doesn't work? When do you call your duck() function?
Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
it won't say eric when I click run
Why would it? When do you call your duck() function?
Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
wamidh (September 17th, 2014)
I am meant to call my function? how do I do this?
thank you for your reply.
Yes, you have to call your function. Java won't automatically call your function for you.
However, Java *does* automatically call the main() method for you. That's the whole point of the main() method.
Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
oh, thank you but what do I write to call my function duck?
I tried that out but then it said cannot make static reference to non-static method duck() from the type Wamidh.
Then I changed the duck function to static and then it worked!
I don't know if it's right but at least it works now.
In all fairness, all i did was copy your 2nd post and replace // TODO Auto-generated method stub with duck();
I didn't even look at anything else. Good on you figuring out static. =)
Be careful. Just sticking static in everywhere is not a good solution and goes against OO principals.
Improving the world one idiot at a time!
KevinWorkman (September 18th, 2014)
okay, thank you.