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. Methods With Parameters

    Discussed in my last post was how we implement multiple classes and execute methods from within these classes via the main class. We can actually send variables from the main class into a method of the secondary class and then use those variables as desired. We do this through the use of parameters. Let me show you what I mean. Here's class2 and what it does.

    public class class2{
    	public void class2Method(String name){
    		System.out.println("Hello "+name);
    ...
    Categories
    Uncategorized
  2. Multiple Classes

    In each Java application, you're going to have a series of classes containing various instructions for the compiler. Each class can be responsible for different actions or functionality of the program.

    Below is our first class, appropriately named class1.

    class class1{
    	public static void main(String args[]){
    		System.out.println("This code is executed via class1!")
    	}
    }

    Let's say that class1 is responsible for a ...
    Categories
    Uncategorized
  3. 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
  4. 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
  5. 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
Page 7 of 13 FirstFirst ... 56789 ... LastLast