Page 2 of 2 FirstFirst 12
Results 21 to 23 of 23
  1. #21
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by gib65 View Post
    What was that???
    JosAH was commenting on a hijack post that I've deleted. In short, he was looking after both your and the forum's best interests.

  2. #22
    gib65 is offline Member
    Join Date
    Jun 2010
    Posts
    86
    Rep Power
    0

    Default

    Thanks Norm,

    One last question: what are the standards for initializing class variables? Is it standard to initialize every single one, or only if you know what its initial value is supposed to be.

    For example, it seems kind of a waste to do this:

    Java Code:
    public class MyClass {
    
        private Color c = null;
    
        public MyClass() {
            c = new Color(255, 0, 255);
        }
    }
    Probably this would be best:

    Java Code:
    public class MyClass {
    
        private Color c;
    
        public MyClass() {
            c = new Color(255, 0, 255);
        }
    }

  3. #23
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,006
    Rep Power
    20

    Default

    For class variables (aka attributes) there's no point initialising them unless that initialisation has meaning, otherwise may as well leave them as default (which is 0 for primitives and null for Objects)...so that initialisation you show up there is actually pointless since that's what c would be defaulted to anyway.

Page 2 of 2 FirstFirst 12

Similar Threads

  1. Need help coding
    By ace_03 in forum New To Java
    Replies: 2
    Last Post: 11-25-2009, 05:16 PM
  2. Coding help
    By Java_Fanatic in forum New To Java
    Replies: 7
    Last Post: 10-15-2009, 04:37 AM
  3. Replies: 2
    Last Post: 03-17-2009, 04:50 PM
  4. coding help
    By accies76 in forum New To Java
    Replies: 5
    Last Post: 11-12-2008, 08:15 PM
  5. Hibernate Standards
    By udayadas in forum JDBC
    Replies: 0
    Last Post: 08-23-2008, 07:28 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •