-3

Photo of almost identical functions

I am trying to create a separate function for creating a random 2d array map, but I don't understand why GameEngine is able to compile but Engine throws errors when they're identical apart from their names. Engine needs void because it does not return anything, but why does this not apply to GameEngine when it clearly returns nothing aswell?

NoLove
  • 1
  • 1
  • 3
    Please copy and paste the code into your question. Pics of code are almost useless. – markspace Jun 01 '21 at 01:17
  • Does this answer your question? [Methods vs Constructors in Java](https://stackoverflow.com/questions/19061599/methods-vs-constructors-in-java) – markspace Jun 01 '21 at 01:26
  • Incomprehensible title. 'Error' is not a verb. Errors are printed. Exceptions are thrown. Don't misuse standard terminology. – user207421 Jun 01 '21 at 01:40

1 Answers1

0

I would assume GameEngine is a java constructor (is your class name GameEngine?); methods other than constructors will need a return type.

yanjunk
  • 336
  • 1
  • 5
  • And if `Engine()` is inside the `Game` class, then it can't be constructor for `Game`. Hence the error message. – markspace Jun 01 '21 at 01:18
  • Thank you so much this was it! The class was named GameEngine and I now understand how constructors differ from regular methods, Cheers! – NoLove Jun 01 '21 at 01:22