+ 1
Help (comment java)
Friends, I have a request and I'm a little embarrassed about it, I have written two programs in Java, but I want to write comments with each line, and to be frank with you, I tried a lot to write comments for the codes, but I find it difficult to express and what can I write, I want you to help me and write comments explaining each code, please Lol thank you
31 Answers
+ 8
STOP do you mean like this
public class Program
{
public static void main(String[] args) {
int i=1,odd=1,even=-2;
/* I am using a while loop to preform 20 times */
while(i<=20)
{
/* here I am beginning to sort numbers into even and odd numbers */
if(i%2==0)
{
System.out.print(even);
System.out.print(" ");
/* if the number is even I want to subtract 2 */
even-=2;
}
else
{
System.out.print(odd);
System.out.print(" "); /* if the number is odd I want to add 2 */
odd+=2;
}
/* here I am adding 1 to i to continue my loop count */
i+=1;
}
}
}
+ 7
Post ur code
+ 5
STOP /* Hello Im done */
really basic coder comment
+ 3
STOP
public class Program
{
public static void main(String[] args) {
int i=2;
/* I am using the while loop to count 20 times */
while(i<=20)
{
/* Here I am adding 1 to every even number to make it odd */
System.out.print(i+1+" ");
i+=2;
}
/* This is my identifier that the while loop has finished */
System.out.print("\nDone");
/* As to why it stopped at 21 not at 20 is because when I reached 20 on the last loop it became 21 */
}
}
+ 3
U can add comments to any line in Java by
//.....-single line comment
/*....*/multiple line comment
/*.....documentation comment
Happy diwali,๐
+ 2
Maedeh Es , Fineb Alex , and The INDIAN (BROโบAkanksha) You should read the other comments in the thread before answering. She knows how to write a comment, but isnt very good at explaining what its doing.
+ 2
Thomas thank you thomas๐๐ป
+ 1
https://code.sololearn.com/cod0m45lOQhW This code 1
https://code.sololearn.com/cbJ2l0UAidlY This code 2
+ 1
BroFar Thank you Thank you ๐ฅบ๐๐
+ 1
Welcome STOP ๐
+ 1
Am I understanding your question correctly: You know how to write comments, but you arent good at explaining what the code is doing in your comment?
+ 1
STOP What exactly do you want me to comment? Should I explain every block of code that does something, or just the main 3 parts?
+ 1
STOP Ok.
+ 1
STOP You're welcome. I also edited it a bit so the name would have a space before and after it.
0
BroFar i need explain comment dear bro , and thank you
0
BroFar yes bro really thankyou .. i cant said how you are help me !โค๏ธ
can you make comment for the other code?
0
Thomas yeeess๐๐ป๐๐ป๐๐ป๐
0
STOP Ok. If you arent understanding what the code is doing, then I recommend learning more about Java. If you understand what its doing but just can explain it, then I would recommend learning more english (I assume you arent a native speaker from your profile and how you talk).