+ 2

Help w/h Java code!

can any one has time to explain plzz ...why this code is not running ? what is the problem? https://code.sololearn.com/c1wa3x5zt2mH/?ref=app

5th Mar 2018, 1:50 PM
Pooja chouhan
Pooja chouhan - avatar
2 odpowiedzi
+ 3
There is a thing in java...that...suppose you have a method...of certain class now u just created an obj. of that class in void main perfectly fine now u called obj.method()...it works now suppose u have inner/sub/nested classes..like the one u hav.. certainly u cant have 2 main methods... okay now u cant call a method outside a method... i mean>> line 6...b.think() produces no error as it is called in a constructor...(which is by default a method also...) now line 11....n.cell()..produces error.. because its not in any method or constructor.. just do this... Brain( ){ n.cell( ); } //in a constructor...and your code will work
5th Mar 2018, 4:03 PM
sayan chandra
sayan chandra - avatar
+ 1
is that the whole sorce code?
5th Mar 2018, 2:14 PM
Ulisses Cruz
Ulisses Cruz - avatar