This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Hey people, a small question on comments: I found this on John Hunts mock questions.
I take it that everything from the first /* at the class decleration does not finish the comments until it finds the opposing comment tag of */ before the print statement that has the String "The end".??? Davy
The /* and */ are similar to brackets, braces, and parentisis (forgive my carpy spelling, two). Once you open one, you need to close it. so, yes, if you have a /*, the comment does not end until it finds a matching */. EVERYTHING is a comment after that opener, until it finds the closer. even antoher open comment... int x; /* x cooridinate of point */ int y; /* y coordinate of point int z; /* z coordinate of point */ note that i "forgot" one of the closing comments. this is legal. the comment starts on the second line, and all of the third line is commented out. the fact that there is a second "open comment" is ignored - it's commented out!!!
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
to clarify, what they have posted is the same as this:
Joined: Jan 12, 2004
thanks Fred, so when I see comments like: /* well this is a comment line * this is another * and this is another */ the extra stars just make it easier for programmers to read and do nothing! Cheers Fred. Davy
you got it!!! what you see here is one big, multi-line comment. many of the fancier editors (Eclipse, Jbuilder, etc) make this even easier. they color-code the different kinds of things in your code. i have mine set up to put all comments in green, keywords in a light blue, object refs in white, etc. it becomes quite obvious when you forget to close your comment - you have 30 lines of gree code!!! it's still better to learn java using notepad or something that makes you think about what you're doing first. THEN move to the tools that make the basics easier
Originally posted by Davy Kelly: so when I see comments like: /* well this is a comment line * this is another * and this is another */ the extra stars just make it easier for programmers to read and do nothing!
If I recall correctly, in older versions of the JavaDoc tool, preformatted code examples needed to appear on lines that began with a *. I believe this requirement has been removed from the JavaDoc tool.
Thanks, it is just that the distance learning company I am learning from, uses this all the time. I am doing the 1.2 exam, because they say I have to do it, but i will eventually move on to the next version once i have completed my studies. thanks Davy