+ 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

12th Nov 2020, 5:15 PM
STOP
STOP - avatar
31 odpowiedzi
+ 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; } } }
12th Nov 2020, 6:03 PM
BroFar
BroFar - avatar
+ 7
Post ur code
12th Nov 2020, 5:16 PM
Alphin K Sajan
Alphin K Sajan - avatar
+ 5
STOP /* Hello Im done */ really basic coder comment
12th Nov 2020, 5:49 PM
BroFar
BroFar - avatar
+ 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 */ } }
12th Nov 2020, 6:10 PM
BroFar
BroFar - avatar
+ 3
U can add comments to any line in Java by //.....-single line comment /*....*/multiple line comment /*.....documentation comment Happy diwali,😍
14th Nov 2020, 3:24 AM
The INDIAN
The INDIAN - avatar
+ 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.
14th Nov 2020, 6:38 PM
Aria
Aria - avatar
+ 2
Thomas thank you thomas👍🏻
14th Nov 2020, 6:39 PM
STOP
STOP - avatar
12th Nov 2020, 5:23 PM
STOP
STOP - avatar
+ 1
BroFar Thank you Thank you 🥺💕💕
12th Nov 2020, 6:32 PM
STOP
STOP - avatar
+ 1
Welcome STOP 😁
12th Nov 2020, 6:41 PM
BroFar
BroFar - avatar
+ 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?
12th Nov 2020, 11:45 PM
Aria
Aria - avatar
+ 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?
20th Nov 2020, 1:33 AM
Aria
Aria - avatar
+ 1
STOP Ok.
20th Nov 2020, 4:12 AM
Aria
Aria - avatar
+ 1
STOP You're welcome. I also edited it a bit so the name would have a space before and after it.
20th Nov 2020, 4:23 AM
Aria
Aria - avatar
12th Nov 2020, 5:27 PM
STOP
STOP - avatar
0
BroFar i need explain comment dear bro , and thank you
12th Nov 2020, 5:53 PM
STOP
STOP - avatar
0
BroFar yes bro really thankyou .. i cant said how you are help me !❤️ can you make comment for the other code?
12th Nov 2020, 6:04 PM
STOP
STOP - avatar
0
Thomas yeeess👍🏻👍🏻👍🏻😂
12th Nov 2020, 11:46 PM
STOP
STOP - avatar
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).
12th Nov 2020, 11:59 PM
Aria
Aria - avatar