Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Help me with Java.

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone!

I´m here again boring you:) (hope not)

there is the thing: i´m running this java code in comand promt but it gives me this error:

Main method not found in class DrumKit, please define the main method as:
public static void main(String[] args)

There is my code:
class DrumKit{

boolean topHat = true;
boolean snare = true;

void playSnare(){
System.out.println("bang bang ba-bang");
}
void playTopHat(){
System.out.println("ding ding da-ding");
}
}

class DrumKitTestDrive{
public static void main(String[] args){

DrumKit d = new DrumKit();

d.playSnare();
d.snare=false;
d.playTopHat();
if(d.snare == true){
d.playSnare();
}
}
}

thanks for your time.
 
Bartender
Posts: 1558
5
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Rui,

Welcome to CodeRanch!

Please, UseCodeTags. It makes reading the code much easier.

Coming to your question - the error is self explanatory.

However, I'm wondering - how are you running your code? Because, I can see that there is main method in DrumKitTestDrive class.

Are you running your code as
or

Maybe you are running as second command mentioned above - which is giving error regarding main method.

I hope this helps.
 
Rui Sousa
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Anayonkar Shivalkar wrote:Hi Rui,

Welcome to CodeRanch!

Please, UseCodeTags. It makes reading the code much easier.

Coming to your question - the error is self explanatory.

However, I'm wondering - how are you running your code? Because, I can see that there is main method in DrumKitTestDrive class.

Are you running your code as
or

Maybe you are running as second command mentioned above - which is giving error regarding main method.

I hope this helps.




Thanks, appreciate your help, that was the issue.

 
Can you smell this for me? I think this tiny ad smells like blueberry pie!
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic