Java main

Hello world,

So I’m on Object Oriented Java lesson 6 “the main method” and it’s very confusing about what I’m actually supposed to do with my code. This is what i have in my code:

class Dog {

int age;

	public static Dog(int dogsAge[] args) {

age = dogsAge;


what the error tells me is “Make sure the main method in your Dog class matches the example correctly.” Which it looks just like the example in the question.

Please help, thanks in advance.

well the example you have must be wrong. dogsAge cannot be instanced anywhere outside a method or constructor.

class Dog{
int age;
public static Dog(int dogsAge[]args){

This is what the code should look like.

And whenever you get that “main” method error it’s just telling you that you need to make sure that your code is accordingly illustrated to abide by the rules of compilation. Compilation means the downward flow of reading a file. And the rules are:

public static void main(String[]args){
//This is the main class. The one every application with a start button should have.
//This method is pure intention and does anything possible for a programmer.
//public(I'm available on any package or app), static(I'm available anywhere in the class and
// up for grabs by any situation, void(I'm not hard to compile), and main(I mean c'mon, I'm the main dog).

There’s an error on this objective. Just reset the code and you’re good to go (Y)

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.