What happens if static is not written while declaring a method? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

What happens if static is not written while declaring a method?

If im just typing void fn_name() Will it show any error? If yes, why is that?

3rd Jul 2018, 1:39 PM
Baskaran Panneerselvam
1 Answer
+ 6
Actually, no error will occur. To call that method, you need to create instance of a class. class Student { public static void main (String[] atgs){ Student std= new Student(); std.f n_Name(); }}
3rd Jul 2018, 1:49 PM
Muhd Khairul Amirin
Muhd Khairul Amirin - avatar