Click here to Skip to main content
15,904,638 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i hav e one question regarding the java please tell me the reason
C#
class M{
public static void main(String[] args) {
M m=new M();
m.a();
System.out.println(m.a());
}
void a(){
System.out.println("Ok");
}
}

answer become 
Void type not allowed here"
Posted

1 solution

You pass m.a() as argument to the println function, but the return type of a() is void, and you cannot pass that as argument.

You really don't need to wrap m.a() inside println, because when you call the a method, it already prints something.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 3-Sep-14 12:08pm    
5ed.
—SA
Thomas Daniels 3-Sep-14 12:11pm    
Thank you!
CPallini 3-Sep-14 12:35pm    
5.
Thomas Daniels 3-Sep-14 12:35pm    
Thank you!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900