Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

View RSS Feed

All Blog Entries

  1. JD1's Personal Development Blog

    Quote Originally Posted by KevinWorkman View Post
    From the standard naming conventions: "Braces are used around all statements, even single statements, when they are part of a control structure, such as a if-else or for statement. This makes it easier to add statements without accidentally introducing bugs due to forgetting to add braces."

    And from experience, not using brackets leads to more confusion than you'd think it would- for you and for people reading your code.



    It's not just the number
    ...
    Categories
    Uncategorized
  2. JD1's Personal Development Blog

    Hi Kevin,

    Thanks for your input. Can you briefly explain why it is necessary to encase single statement If Statements in brackets? I get that it's a global programming convention to do this, just incase you need to go back and add something else, but is there a more latent reason?

    I'm definitely going to be using more Switch Statements. I guess it would be more effective to use an If Statement if you're testing one condition, or even if you're testing two (use Else ...
    Categories
    Uncategorized
  3. JD1's Personal Development Blog

    Quote Originally Posted by KevinWorkman View Post
    Just a few words of advice, take them or leave them:

    Even if an if or a loop only consists of a single statement, you should still surround it with {brackets}. This is not only a standard Java convention, but I promise it'll save you a headache in the future.

    And perhaps I can clear up some of your thoughts on the switch statement.

    You use an if statement to test conditions, the operands of which you might not know at compile time, because they can change
    ...
    Categories
    Uncategorized
  4. The While Loop

    The While Loop is an excellent way of outputting data until reaching a specific point. It's used by running instructions until a condition is no longer true. Basically, it's going to keep running the same set of instructions until the specified condition is modified so as to be false, to reiterate. Sometimes, While Loops can create infinite loops. Usually, While Loops have an instruction at the end of the instruction set which modifies (usually increments) a counter variable being used in the condition ...
    Categories
    Uncategorized
  5. The Switch Statement

    It's to my understanding that the Switch Statement is used as a means of saving time. If you want to test multiple conditions, but are looking for a more efficient way of doing things than using the If or Else If Statements, the Switch Statement is the way to go. I have trouble remembering what the switch statement means because I fail to make its connection to the 'case' keyword. The 'case' is the most important part of the switch statement. I know I'll be able to remember to use the switch statement ...
    Categories
    Uncategorized
Page 8 of 14 FirstFirst ... 678910 ... LastLast