JavaRanch Home    
 
This page:         last edited 29 March 2014         What's Changed?         Edit
PROTECTED

Use Code Tags   

One of the most important tactics for getting answers to your questions effectively is making your post easy to read. And one of the most important practices to make your post more easy to read is to put code tags around your code examples.

It's really easy: just put [code] tags around your code, such as in

[code=java]
System.out.println("Hello world.");
[/code]

Or just use the appropriate "code" button above the edit area.

That way, the formatting of your code will be preserved, and people who read your post don't need to waste valuable brain cycles on deciphering it - they can use them instead to formulate the answer to your question! Taking the time to ensure that your code is presented properly shows that you respect everyone's time enough to ShowSomeEffort when posting your question.

If you forget to do this when posting some code, you can edit your post for a short period afterwards by clicking on the Edit icon at its right top.

NOTE: Please keep lines inside code blocks under 80 characters. Firstly, it's easier to read; secondly, excessively long lines tend to mess up the windowing, making threads hard to read - particularly if you don't have very high screen resolutions.

Tip: (and this applies to any post) Before you submit, always use the 'Preview' button to check your post. If you see an active scrollbar at the bottom of any of your code blocks; it means that it contains lines that are definitely too long, but 80 characters is even better.

Finally, note that most people won't even try to read your code if you post much more than about 15 to 20 lines. Before you post your entire program and say "what's wrong with this?", try to isolate the portion where the problem lies and just post that.

When possible, post an SSCCE (Short Self-Contained Correct Example).

Also take a look on our other tips on HowToAskQuestionsOnJavaRanch. And for advanced options like languages and how to change the starting line number, see RanchGuide


JavaRanchContact us — Copyright © 1998-2014 Paul Wheaton