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.

Page 1 of 3 123 LastLast
Results 1 to 25 of 71

Thread: JD1's Personal Development Blog

  1. #1
    Member OA-OD-JD1's Avatar
    Join Date
    Jan 2012
    Location
    Australia
    Posts
    69
    My Mood
    Inspired
    Thanks
    9
    Thanked 1 Time in 1 Post
    Blog Entries
    29

    Default JD1's Personal Development Blog

    Hello everyone,

    Firstly, I'd like to apologise if this thread's in the wrong forum. There wasn't anything that was going to really suit the topic of this thread. As posted in my introduction, I'm going to do my best to learn as much as possible about the Java programming language over the next year (and afterwards, of course).

    To help me cement some of the new found knowledge I'm receiving via tutorials and guides, I've decided to keep this thread as my personal location for posting what I'm learning about, any questions I might have, and code snippets I'm working with. That is, of course, if that's alright with the staff of JPF.

    Unless you have anything to contribute; perhaps you can answer a question of mine or make a comment on what I'm doing, I'd ask that you let me be. Don't get me wrong, I'm all for assistance - that's what I need most. I just want to keep this thread as a collection of my personal work, so I'd like all discussion here directly relevant to what I'm posting, if that's alright.

    Thanks,
    OA-OD-JD1


  2. #2
    Member OA-OD-JD1's Avatar
    Join Date
    Jan 2012
    Location
    Australia
    Posts
    69
    My Mood
    Inspired
    Thanks
    9
    Thanked 1 Time in 1 Post
    Blog Entries
    29

    Default The If Statement

    From prior programming experience, I'm well aware of what an If Statement is. I'm just going to quickly go over its syntax so I don't forget!

    Single Line If Statement Without Else Clause

    if(condition)
       instructions if condition proves true (confined to one line of instructions)...

    Single Line If Statement With Else Clause

    if(condition)
       instructions if condition proves true (confined to one line of instructions)...
    else
       instructions if condition proves false (confined to one line of instructions)...

    Multiple Line If Statement Without Else Clause

    if(condition){
       instructions if condition proves true...
       instructions if condition proves true...
    }

    Multiple Line If Statement With Multiple Line Else Clause

    if(condition){
       instructions if condition proves true...
       instructions if condition proves true...
    }else{
       instructions if condition proves false...
       instructions if condition proves false...
    }

    Else If Statement

    if(condition){
       instructions if condition proves true...
    }else if(condition){
       instructions if condition proves true...
    }else{
       instructions if condition proves false...
    }

    Java Example

    if(age<13){
       System.out.println("You are not yet a teenager!");
       System.out.println("You are most definitely 12 or younger!");
    }else{
       System.out.println("You might be a teenager!");
       System.out.println("You are definitely older than 12!");
    }

    Important Note

    Even though it isn't vital to include braces around single line If Statements, it's still advised. This is because, for example, if you wanted to go back and add code to a particular statement, you will have to then add the braces. Often people can overlook this and it's just a bug waiting to happen. This is the case for all statements, not just If Statements.
    Last edited by OA-OD-JD1; January 25th, 2012 at 10:28 PM.

  3. #3
    Member OA-OD-JD1's Avatar
    Join Date
    Jan 2012
    Location
    Australia
    Posts
    69
    My Mood
    Inspired
    Thanks
    9
    Thanked 1 Time in 1 Post
    Blog Entries
    29

    Default 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 more frequently if I can realise its relationship with the 'case' structure. Basically, think of switch; think of case.

    Switch Statement

    switch(variable){
    case firstcondition:
       instructions if firstcondition is true...
       instructions if firstcondition is true...
       instructions if firstcondition is true...
       break;
    case secondcondition:
       instructions if secondcondition is true...
       instructions if secondcondition is true...
       instructions if secondcondition is true...
       break;
    case thirdcondition:
       instructions if thirdcondition is true...
       instructions if thirdcondition is true...
       instructions if thirdcondition is true...
       break;
    default:
       instructions if all above conditions are false...
       instructions if all above conditions are false...
       instructions if all above conditions are false...
       break;
    }
    Note: The 'break;' isn't always going to be present. You only use break if you want to exit the Switch Statement if the current condition proves true. In some situations, it will pay to go through several conditions of the Switch Statement regardless of whether the current one is true or not. However, in most cases, the 'break;' will be necessary.

    Java Example

    switch(age){
    case 1:
       System.out.println("You're 1 year old!");
       break;
    case 2:
       System.out.println("You're 2 years old!");
       break;
    case 3:
       System.out.println("You're 3 years old!");
       break;
    default:
       System.out.printkn("I don't know how old you are!");
       break;
    }

  4. #4
    Member OA-OD-JD1's Avatar
    Join Date
    Jan 2012
    Location
    Australia
    Posts
    69
    My Mood
    Inspired
    Thanks
    9
    Thanked 1 Time in 1 Post
    Blog Entries
    29

    Default 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 so as to bring the condition closer to being false.

    Single Line While Loop

    while(condition)
       instructions if condition proves true...

    Multiple Line While Loop

    while(condition){
       instructions if condition proves true...
       instructions if condition proves true...
    }

    Java Example

    while(age<13){
       System.out.println("You are "+age+" years old. You are not yet a teenager!");
       age++;
    }

  5. #5
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: JD1's Personal Development Blog

    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 depending on program flow. But a subsection of those cases exists where you do know the value of one of the operands at compile time, and you're simply testing whether the other operand is equal to any of those known values. That's when you use a switch statement. It's not just more efficient, but once you're used to it, the syntax is also easier to read (easier to read than a bunch of if statements), which makes it easier to debug and harder to screw up.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  6. The Following User Says Thank You to KevinWorkman For This Useful Post:

    OA-OD-JD1 (January 25th, 2012)

  7. #6
    Member OA-OD-JD1's Avatar
    Join Date
    Jan 2012
    Location
    Australia
    Posts
    69
    My Mood
    Inspired
    Thanks
    9
    Thanked 1 Time in 1 Post
    Blog Entries
    29

    Default Re: 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 depending on program flow. But a subsection of those cases exists where you do know the value of one of the operands at compile time, and you're simply testing whether the other operand is equal to any of those known values. That's when you use a switch statement. It's not just more efficient, but once you're used to it, the syntax is also easier to read (easier to read than a bunch of if statements), which makes it easier to debug and harder to screw up.
    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 If). But as soon as there's three conditions or more to be tested, I'm thinking I'll go for the Switch Statement. Is this advisable?

    Thanks,
    OA-OD-JD1

  8. #7
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: JD1's Personal Development Blog

    Quote Originally Posted by OA-OD-JD1 View Post
    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?
    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.

    Quote Originally Posted by OA-OD-JD1 View Post
    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 If). But as soon as there's three conditions or more to be tested, I'm thinking I'll go for the Switch Statement. Is this advisable?
    It's not just the number of conditions, it's also the idea of knowing one of the operands of the condition ahead of time, at compile-time.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  9. The Following User Says Thank You to KevinWorkman For This Useful Post:

    OA-OD-JD1 (January 25th, 2012)

  10. #8
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 294 Times in 227 Posts
    Blog Entries
    4

    Default Re: JD1's Personal Development Blog

    If you are serious about blogging your progress here, I will grant you Blog permissions. PM me.
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

  11. The Following User Says Thank You to JavaPF For This Useful Post:

    OA-OD-JD1 (January 25th, 2012)

  12. #9
    Member OA-OD-JD1's Avatar
    Join Date
    Jan 2012
    Location
    Australia
    Posts
    69
    My Mood
    Inspired
    Thanks
    9
    Thanked 1 Time in 1 Post
    Blog Entries
    29

    Default Re: JD1's Personal Development Blog

    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.
    Thanks for sharing that. I'll definitely be using braces for all If Statements (and probably others too, where appropriate).

    It's not just the number of conditions, it's also the idea of knowing one of the operands of the condition ahead of time, at compile-time.
    I'm not 100% sure I understand you just yet. Would you be able to share an example?

    Quote Originally Posted by JavaPF View Post
    If you are serious about blogging your progress here, I will grant you Blog permissions. PM me.
    I'd really like that. Hopefully by maintaining an official blog, I can help out others as they make a similar journey into the world of Java. I appreciate this.

    Thanks,
    OA-OD-JD1
    Last edited by OA-OD-JD1; January 24th, 2012 at 05:01 PM.

  13. #10
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,133
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: JD1's Personal Development Blog

    I'll definitely be using braces for all If Statements
    Don't limit their use to if statements.
    There is always a time you decide later and in a hurry to insert some statement at the front end of some code that is naked (without {}s) and voila a bug.
    If you always add the { a blank line and the ending } you'll save yourself a few gotchas.

  14. #11
    Member OA-OD-JD1's Avatar
    Join Date
    Jan 2012
    Location
    Australia
    Posts
    69
    My Mood
    Inspired
    Thanks
    9
    Thanked 1 Time in 1 Post
    Blog Entries
    29

    Default Re: JD1's Personal Development Blog

    Quote Originally Posted by Norm View Post
    Don't limit their use to if statements.
    There is always a time you decide later and in a hurry to insert some statement at the front end of some code that is naked (without {}s) and voila a bug.
    If you always add the { a blank line and the ending } you'll save yourself a few gotchas.
    And in terms of effiency, the braces really don't make much of a difference, do they?

  15. #12
    Think of me.... Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Pakistan
    Posts
    1,136
    My Mood
    Grumpy
    Thanks
    20
    Thanked 82 Times in 78 Posts
    Blog Entries
    1

    Default Re: JD1's Personal Development Blog

    Quote Originally Posted by OA-OD-JD1 View Post
    And in terms of effiency, the braces really don't make much of a difference, do they?
    No, braces don't really effect efficiency but the actual thing is if you are too beginner, don't just leave using braces whether it's a single statement as mentioned by others, this can in the end lead you to the huge trouble......

  16. #13
    Member OA-OD-JD1's Avatar
    Join Date
    Jan 2012
    Location
    Australia
    Posts
    69
    My Mood
    Inspired
    Thanks
    9
    Thanked 1 Time in 1 Post
    Blog Entries
    29

    Default 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 few introductory things, such as a welcome message and lastly referencing the other classes into action. That's often the main role of the first class, to call other classes and execute code from within them. Below is our second class.

    public class class2{
    	public void class2Method(){
    		System.out.println("This code is executed via class2!");
    	}
    }

    Right now we have two separate classes. We can use class1 fine, but if we want to access class2, we're going to need to say so in class1, since that is our main class containing our main method. We can do this by adding some code to class1.

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

    We've added two new lines of code to class1.

    class2 class2Object=new class2();
    class2Object.class2Method();

    The first line creates a class2 object we can use to implement methods from within that class. To create this object, you must first write the class name (in our case, it's class2). Then, you must write the name of the object you'd like to use to reference that class, it can be anything. I've kept it simple with class2Object. And lastly, write =new because we're creating a new object, followed by the name of the class once again (class2). This is shown above for your reference.

    We now have a class2 object we can use to execute methods from within the second class. To actually do this, you must write the object name, followed by a dot separator, followed by the name of the method from within that class (class2Method). Your application will now execute everything from within that method of that class.
    Last edited by OA-OD-JD1; January 25th, 2012 at 07:33 AM.

  17. #14
    Member OA-OD-JD1's Avatar
    Join Date
    Jan 2012
    Location
    Australia
    Posts
    69
    My Mood
    Inspired
    Thanks
    9
    Thanked 1 Time in 1 Post
    Blog Entries
    29

    Default Re: JD1's Personal Development Blog

    Quote Originally Posted by Mr.777 View Post
    No, braces don't really effect efficiency but the actual thing is if you are too beginner, don't just leave using braces whether it's a single statement as mentioned by others, this can in the end lead you to the huge trouble......
    No worries. I'll make sure to implement braces in every statement from now on. Thanks.

  18. #15
    Think of me.... Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Pakistan
    Posts
    1,136
    My Mood
    Grumpy
    Thanks
    20
    Thanked 82 Times in 78 Posts
    Blog Entries
    1

    Default Re: JD1's Personal Development Blog

    @OA-OD-JD1: Though you are learning Java but you must need to know the naming conventions for variables, constants, methods, classes, interfaces etc....
    So, follow the Sun naming conventions in order to have a good programming experience (Java)

  19. #16
    Member OA-OD-JD1's Avatar
    Join Date
    Jan 2012
    Location
    Australia
    Posts
    69
    My Mood
    Inspired
    Thanks
    9
    Thanked 1 Time in 1 Post
    Blog Entries
    29

    Default 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);
    	}
    }

    You'll notice that we have included String name as our parameters this time round. That's because, we want to get the string 'name' from our main class and output its value. Seems simple enough right? All we have to do now is tell our class1 to send this variable through. Here's class1, containing our main method.

    class class1{
    	public static void main(String args[]){
    		System.out.println("This code is executed via the main method in class1!");
    		class2 class2Object=new class2();
    		String name="Tony";
    		class2Object.class2Method(name);
    	}
    }

    You'll notice that we've created a new class2 object named class2Object. This allows us to use class2 and execute code from within. Next, we created a new string variable called name. This is the variable we want to send through to the second class. We've assigned it a value of 'Tony'. We can send this variable through to the second class by using our class2 object, a dot separator, the method from within class2 that we want to output, and the parameter of 'name' (the variable we're sending).

    So long as the variable you use in class2Object.class2Method(name);, which would be 'name', matches the variable used in public void class2Method(String name){, you should be right to go ahead and use this variable from within class2.

  20. #17
    Member OA-OD-JD1's Avatar
    Join Date
    Jan 2012
    Location
    Australia
    Posts
    69
    My Mood
    Inspired
    Thanks
    9
    Thanked 1 Time in 1 Post
    Blog Entries
    29

    Default Re: JD1's Personal Development Blog

    Quote Originally Posted by Mr.777 View Post
    @OA-OD-JD1: Though you are learning Java but you must need to know the naming conventions for variables, constants, methods, classes, interfaces etc....
    So, follow the Sun naming conventions in order to have a good programming experience (Java)
    The reason I've used such odd class names and variable names is to help paint a picture in the reader's head (my head). These simple names aren't meant to uphold the various naming conventions, but are more aimed towards enabling me to fully understand what's going on and what's what.

  21. #18
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,133
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: JD1's Personal Development Blog

    Some more comments on your coding style;
    Class names should start with uppercase letters:
    class class1{
    vs
    class Class1{

    Put some white space in the statement to make them easier to read:
    String name="Tony";
    vs
    String name = "Tony";

  22. The Following User Says Thank You to Norm For This Useful Post:

    OA-OD-JD1 (January 25th, 2012)

  23. #19
    Member OA-OD-JD1's Avatar
    Join Date
    Jan 2012
    Location
    Australia
    Posts
    69
    My Mood
    Inspired
    Thanks
    9
    Thanked 1 Time in 1 Post
    Blog Entries
    29

    Default Re: JD1's Personal Development Blog

    Quote Originally Posted by Norm View Post
    Some more comments on your coding style;
    Class names should start with uppercase letters:
    class class1{
    vs
    class Class1{

    Put some white space in the statement to make them easier to read:
    String name="Tony";
    vs
    String name = "Tony";
    I'll keep that in mind when creating class names. I don't know what it is, but I actually enjoy using as little white space as possible. I like jamming everything together. I know it's not the best way to go about things, but it works for me so I'm going to stick to is. Thanks, Norm.

  24. #20
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,133
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: JD1's Personal Development Blog

    As long as you don't care if anyone else can look at your code and understand it, you are free to do it any way you want.
    Then why are you posting your code here?

  25. The Following 2 Users Say Thank You to Norm For This Useful Post:

    KevinWorkman (January 25th, 2012), Mr.777 (January 25th, 2012)

  26. #21
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 294 Times in 227 Posts
    Blog Entries
    4

    Default Re: JD1's Personal Development Blog

    OA-OD-JD1, I'd listen to Norm and KevinWorkman, these guys are where you want to be.
    Convention is massively important. Play by the rules now and you won't have to adjust your coding style in the future.
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

  27. The Following User Says Thank You to JavaPF For This Useful Post:

    KevinWorkman (January 25th, 2012)

  28. #22
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: JD1's Personal Development Blog

    Quote Originally Posted by OA-OD-JD1 View Post
    I'm not 100% sure I understand you just yet. Would you be able to share an example?

    Case expressions must be constant values. So if you don't know the values ahead of time (if it's based on some calculation that might change, for example), then you can't use a switch.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  29. The Following User Says Thank You to KevinWorkman For This Useful Post:

    OA-OD-JD1 (January 25th, 2012)

  30. #23
    Member OA-OD-JD1's Avatar
    Join Date
    Jan 2012
    Location
    Australia
    Posts
    69
    My Mood
    Inspired
    Thanks
    9
    Thanked 1 Time in 1 Post
    Blog Entries
    29

    Default Re: JD1's Personal Development Blog

    Quote Originally Posted by Norm View Post
    As long as you don't care if anyone else can look at your code and understand it, you are free to do it any way you want.
    Then why are you posting your code here?
    You win. I'll space it out nicely.

    Quote Originally Posted by KevinWorkman View Post
    Case expressions must be constant values. So if you don't know the values ahead of time (if it's based on some calculation that might change, for example), then you can't use a switch.
    Understood.
    Last edited by OA-OD-JD1; January 25th, 2012 at 07:54 PM.

  31. #24
    Member OA-OD-JD1's Avatar
    Join Date
    Jan 2012
    Location
    Australia
    Posts
    69
    My Mood
    Inspired
    Thanks
    9
    Thanked 1 Time in 1 Post
    Blog Entries
    29

    Default I've Learned About A Few General Java/Programming Conventions

    First of all, thanks to the following members for helping me out thus far. I very much appreciate your time and effort and I've decided to take everything on board.




    First of all, KevinWorkman told me of the importance of implementing braces on all statements (If Statements, Switch Statements, etc) regardless of whether there's only one line's code after the condition. If you don't implement braces around these statements and you decide later that you want to add another line of code into a statement, there's a chance you're going to forget to insert your braces. Basically, we do this just to prevent bugs from appearing at compile time.

    Kevin also addressed a question I had about Switch Statements. Instead of using an If/If Else Statement, we use a Switch Statement when we know exactly what one of the operands are ahead of compiling.

    JavaPF then mentioned he would allow me blogging permissions so I could make this an official blog. Hopefully, I'll be moving this blog to an official blog in the near future.

    Norm and Mr.777 then backed up Kevin to cement the importance of using braces always.

    Norm then made two very useful observations about my programming style. First, he made aware to me the fact that classes should start with a capital letter. Instead of using class1, I should have been using Class1. I'll make sure I use proper capitalisation in the future. Norm, I presume that if the name of the class has two words, so to speak, that the first word isn't capitalised and the second is? By this I mean, startRendering. If we were to use that as a class name (for whatever reason), it would be as is instead of StartRendering? Maybe I'm getting this confused with the naming conventions for variables. I'd appreciate if you could clear that up.

    Norm then pointed out that I clustered my code together too much. An example being, if(this==that). I should be spacing it out some more and implementing more white space: if(this == that). I had been under the impression that it wasn't really a big deal whether you made use of spacing or not, but I guess it only makes sense to space it out. If not for yourself, for others.

    That's all for now. I'll be covering some more in-depth information on the use of multiple methods in my next post.

    Thanks everyone,
    JD1

  32. #25
    Member OA-OD-JD1's Avatar
    Join Date
    Jan 2012
    Location
    Australia
    Posts
    69
    My Mood
    Inspired
    Thanks
    9
    Thanked 1 Time in 1 Post
    Blog Entries
    29

    Default Comments

    You can make comments in your Java code in two ways, single line comments, and multiple line comments. Below is a single line comment.

    //This is a single line comment.

    And below is a multiple line comment.

    /*This is a multiple line comment.
    It can span over multiple lines.*/

    Comments are used to explain certain code to yourself and others that may be reading your code.

Page 1 of 3 123 LastLast

Similar Threads

  1. My Personal Spam Test
    By person287 in forum Totally Off Topic
    Replies: 2
    Last Post: December 18th, 2011, 03:06 AM
  2. Blog idea
    By dks in forum Java Theory & Questions
    Replies: 3
    Last Post: February 17th, 2011, 02:48 PM
  3. Advice on Java personal msg system?
    By cyborgbill in forum Java Theory & Questions
    Replies: 1
    Last Post: March 30th, 2010, 03:00 AM