• Post Reply Bookmark Topic Watch Topic
  • New Topic

Help me with this question  RSS feed

 
fatimaafghan kabuli
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have tried to answer the fallowing three questions but not succeed,please help.?

1- Name the THREE types of comments used in Java programming and show how it is used in a Java program.

2- Rewrite the following While statement using a For loop statement.

x = 1;
while (x<=50)
{
System.out.println(x);++x;
}
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch!

What have you come up with so far?

(See How to ask questions on Javaranch - Show some effort.)
 
sudhir nim
Ranch Hand
Posts: 212
Eclipse IDE Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Theres three types of comments.

[edit - removed answer]

A.2
Above loop can be rewritten as
[edit - removed answer]
[ October 10, 2007: Message edited by: Fred Rosenberger ]
 
Campbell Ritchie
Marshal
Posts: 55759
163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Both answers are more-or-less correct, but both could be improved. There are actually four types of comment:
[edit - removed answer]
It is customary, but not essential, to put asterisks at the beginning of each line in block and documentation comments. This is to make it easier for humans to read.You will need to show examples of their use, possibly added to the 50-times loop you showed for A2.

The 50-times loop will work as written, but you would do well to look in the Java Tutorial or other sources for the usual syntax. It is very easy to make mistakes in loops, so you ought to stick to the usual formats.

CR
[ October 10, 2007: Message edited by: Fred Rosenberger ]
 
fred rosenberger
lowercase baba
Bartender
Posts: 12542
48
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have removed the portions of the post that just handed out the answer. we try to focus here on helping people figure things out for themselves, rather than spoon-feeding them answers. it's really to everyone's benefit that way.

I'm hoping the original poster will come back and show some attempt at answering the question themself.
 
Campbell Ritchie
Marshal
Posts: 55759
163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh, sorry, I thought it was the original poster who quoted the three kinds of comment. I ought to learn to read posters' names!
 
Kamal Ahmed
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

[ October 10, 2007: Message edited by: Fred Rosenberger ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!