Bookmark Topic Watch Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Bear Bibeault
  • Liutauras Vilda
  • Devaka Cooray
  • Knute Snortum
  • Junilu Lacar
  • Henry Wong
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
  • salvin francis
  • Frits Walraven
  • Piet Souris
  • Likes 1
  • Mark post as helpful
  • send pies
  • Report post to moderator
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 inOr just use the appropriate "code" button above the edit area. Instead of code=java you can also use code=xml, code=sql, and several others to correctly color code in other languages. Check out the menu to the left of the Code button to see what's available.

Only write code inside the code tags. Anything else in the tags makes it difficult for people to help you. Don't add any formatting tags; if the code contains [b]...[/b] tags or [color=#x003f00]...[/color] tags, people replying to your question cannot copy'n'paste the code to execute it for themselves.
Don't add line numbers; the tags do the numbering automatically starting with line number 1. If you want your code to begin with a line number other than 1 (so that you can post only a portion of your code and keep the stack trace line numbers consistent), use the firstline option:And in the RanchGuide you can find some examples to use other advanced options (e.g. using a different language than Java) as well.

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. And surely it goes without saying that you will post correctly‑formatted code. Except, maybe, if you think your own poor formatting is hiding some other error.

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.
It's just like a fortune cookie, but instead of a cookie, it's pie. And we'll call it ... tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!