object JDWhileLoop
{
def main(args: Array[String])
{
var index:Int = 0
while( index<=10)
{
println("index="+index)
index= index+1
}
}
}
here is the error
JDWhileLoop.scala:3: error: only classes can have declared but
undefined members
def main(args: Array[String])
^
I got this simple code and try to make work,but is not ,I dont know why.please help me. thanks
That’s formatting error. This should be fine:
In your code
def main(args: Array[String])treated as an abstract method (without body) followed by some code block in object inner body definition.Note that in scala the following braces style is preffered