what's wrong with my method declaration | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

what's wrong with my method declaration

public class blah2 { public static void main (String args[]) { double kaka(int [] yo) { double res=0; for (int i = 0; i<yo.length; i++) { res += yo[i] ; double fina = res/4; return fina; } } double num[] = {43.4, 435.55, 65.54}; double sitcom = kaka(num[]);

19th Aug 2016, 6:22 PM
Anshul Rawal
Anshul Rawal - avatar
2 Answers
+ 2
1. methods must be defined within classes, but not within other methods 2. when calling kaka, actually when passing an Array you must not add the brackets ... so rewrite it to kaka(num)
19th Aug 2016, 6:31 PM
maisterlein
0
thanks alot. i was scratching my head on it since last half hour
19th Aug 2016, 6:45 PM
Anshul Rawal
Anshul Rawal - avatar