Semi-colon | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Semi-colon

Why should we not use a semi-colon while declaring a class or after a method? Is there a reason or it just needs to?

11th Sep 2020, 5:05 PM
Ruby
Ruby - avatar
2 Answers
+ 3
Semi-colon is used to indicate instruction end.To separate statement in some languages.C C++ javascript java ...Else compiler can not understand your code.It is used also in clasd declaration in c c++ only.
11th Sep 2020, 6:03 PM
HBhZ_C
HBhZ_C - avatar
+ 2
In java, semi colon denotes end of statement. That's the way syntax of those is designed by the Java developers... Where you actually you are taking about? Can you give an example? After the class means.? Class definition should be like class class_name { ... } //if you mean here, if you put, then it's not error, it's not belongs to class,, and just a unnecessary extra char... Similarly for method.. You just put statements between {//here....} as a block statements....
11th Sep 2020, 6:06 PM
Jayakrishna 🇮🇳