3. Classes:Constructors


#1



class {

public static void main(String[] args) {

}

}

class Dog {

public Dog() {

}
}

Not sure why this seemingly simple code is not working.


#2

"working" along with "wrong" does not describe what is happening other than that it does or does not do what you want which others might not know anything about.

You'll have to describe what is different from what you want.

The code you posted does indeed not compile, I suggest looking up some minimal examples for what you're doing and compare that to your code (see if you can find the information before asking)

You might also read the error message provided by the compiler, at least on my machine, your code results in a rather straight-forward error message:

$ javac nuclear_marine.java 
nuclear_marine.java:1: error: <identifier> expected
class {
     ^
1 error

Errors also tend to be pretty good to use in search queries to find similar questions.


#3

@nuclear_marine You were not suppose to make the class "Dog" in the middle of the code. All you need to do was add the word "Dog" next to "class" in the first line. I don't think what you did was wrong, but the exercise only recognizes a certain number of ways to pass this exercise, but that was not one of them. Your code should look like this:

class Dog{




	public static void main(String[] args) {

	}

}

Hope that works for you! Let me know if you need more help. Good luck and happy coding! :slight_smile:

-- @chipjumper36731


#4

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