0
Getting syntax error
Hi, I'm not able to find my error. I've handled all the brackets but still getting error. Please help. Syntax error on token "{", { expected after this token Syntax error, insert "}" to complete ClassBody https://code.sololearn.com/c1T07fMmHe36/?ref=app
4 Réponses
0
public class EncapsulationIntro{
public static void main(String[] args) {
System.out.println("hello");
}
public void doWork(){
System.out.println("do some work");
}
}
class LivingBeings{
String name;
LivingBeings()
{
this.name = name;
}
}
+ 2
Comment line 1:
Package isn't supported in SoloLearn.
Comment line 23
Invalid syntax, you write statements outside methods.
+ 2
Ankush Raj
You can not write any statement without method or constructor.
So you need to write this.name = name inside a method or constructor.
Remember constructor is also a method but non returnable means you cannot have any return type.
+ 1
Thanks 👍