score:1

the main method needs to be on a toplevel object. your bottles object is wrapped in a main class. remove that main class and your code should run.

object bottles {
  def main(args: array[string]){
    var n : int=2;
    while(n<=6){
      println(s"hello ${n} bottles");
      n+=1;
    }
  }
}

score:2

okay, also had the same error error: "could not find or load main class main" in my scala ide and the reason of that was that when i created main, i immediately moved it to a package.

so i had to:

  • move my main class back to default package.
  • clean, compile, run.

Related Query

More Query from same tag