There also seem to be situations where the compiler chides me that a field might not be initialized, though the exact use case escapes me.
David Graham wrote:
--- Martin Cooper <[EMAIL PROTECTED]> wrote:
Erm, actually, I was referring to the new:
private String label = null;
versus the original (and exactly equivalent, AFAIK):
private String label;
I normally operate under the belief that not everyone knows the rules as well as we do so things like that just make it clearer. There's also a certain symmetry involved when initializing some variables to a value other than its default.
Plus, it gives me a warm fuzzy feeling to know they're set to null.
David
-- Martin Cooper
-----Original Message-----
From: David Graham [mailto:[EMAIL PROTECTED]
Sent: Tuesday, July 01, 2003 9:34 PM
To: Struts Developers List
Subject: RE: cvs commit: jakarta-struts/src/share/org/apache/struts/util
L abelValueBean.java
--- Martin Cooper <[EMAIL PROTECTED]> wrote:
Just curious - what's the reason for explicitly
initialising members to
null, given that that's what happens anyway?
I was just in the mode of calling one constructor from every other
constructor and didn't even think about it. I could have just as easily
called super();. In fact, I think I'll go change that now.
David
jakarta-struts/src/share/org/apache/struts/util-- Martin Cooper
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Tuesday, July 01, 2003 7:20 PM
To: [EMAIL PROTECTED]
Subject: cvs commit:
LabelValueBean.javaLabelValueBean.java
dgraham 2003/07/01 19:20:28
Modified: src/share/org/apache/struts/util
jakarta-struts/src/share/org/apache/struts/util/LabelValueBean.javaLog:
Added default constructor for PR# 18142.
Revision Changes Path
1.3 +14 -11
===================================================================Index: LabelValueBean.java
---------------------------------------------------------------------RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/util/Labe
lValueBean.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- LabelValueBean.java 12 Mar 2002 06:30:56 -0000 1.2
+++ LabelValueBean.java 2 Jul 2003 02:20:28 -0000 1.3
@@ -7,7 +7,7 @@
*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 1999-2001 The Apache Software Foundation. All rights
+ * Copyright (c) 1999-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -59,13 +59,10 @@
*
*/
-
package org.apache.struts.util;
-
import java.io.Serializable;
-
/**
* A simple JavaBean to represent label-value pairs. This is most commonly used
* when constructing user interface elements which have a label to be displayed
@@ -76,7 +73,6 @@
* @author Martin F N Cooper
* @version $Revision$ $Date$
*/
-
public class LabelValueBean implements Serializable {
@@ -84,6 +80,13 @@
/**
+ * Default constructor.
+ */
+ public LabelValueBean() {
+ this(null, null);
+ }
+
+ /**
* Construct an instance with the supplied property values.
*
* @param label The label to be displayed to the user.
@@ -101,7 +104,7 @@
/**
* The property which supplies the option label visible to the end user.
*/
- private String label;
+ private String label = null;
public String getLabel() {
return this.label;
@@ -115,7 +118,7 @@
/**
* The property which supplies the value returned to the server.
*/
- private String value;
+ private String value = null;
public String getValue() {
return this.value;
[EMAIL PROTECTED]To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail:
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
__________________________________ Do you Yahoo!? SBC Yahoo! DSL - Now only $29.95 per month! http://sbc.yahoo.com
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
__________________________________ Do you Yahoo!? SBC Yahoo! DSL - Now only $29.95 per month! http://sbc.yahoo.com
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
-- Ted Husted, Struts in Action <http://husted.com/struts/book.html>
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]