commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Steve Downey <steve.dow...@netfolio.com>
Subject Re: CharRange UNSET ?
Date Sat, 28 Sep 2002 00:27:48 GMT
public class TestDefAssign {
  public static char UNSET;
  public static void main(String[] args) {
  char c;
  char d = 0;
  //System.out.println(d == c);
  //System.out.println(d != c);
  //System.out.println(c);
  System.out.println(d != UNSET);
  System.out.println(d == UNSET);
  //System.out.println(c != UNSET);
  //System.out.println(c == UNSET);
  }
}

Uncomment any of the commented out lines and you get something like
TestDefAssign.java:12: variable c might not have been initialized

The output of the program is
false
true

Which indicates that UNSET actually has the value of 0, but I don't think 
you're supposed to use it.


On Friday 27 September 2002 06:36 pm, Henri Yandell wrote:
> Weird. I'd thought all values in Java were set to a defined value. Thought
> we got rid of the unassigned stuff with C. But I don't delve into the JVM
> and language spec enough so could be wrong very easily.
>
> Hen
>
> On 27 Sep 2002, Steve Downey wrote:
> > CharRange uses an unassigned static character, UNSET, as a flag value
> > for testing if the range is a range or a single value.
> >
> > This looks a little odd to me. I had the distinct impression that
> > accessing an unassigned value was an error. However, the comparison
> > works. I'm just not sure it's working as intended, and won't fail to
> > work an a different VM?
> >
> > relevant code:
> >     /**
> >      * Used internally to represent null in a char.
> >      */
> >     private static char UNSET;
> >
> > // ...
> >
> >     /**
> >      * Is this CharRange over many characters
> >      *
> >      * @return boolean true is many characters
> >      */
> >     public boolean isRange() {
> >         return this.close != UNSET;
> >     }
> >
> >
> >
> >
> >
> >
> > --
> > To unsubscribe, e-mail:  
> > <mailto:commons-dev-unsubscribe@jakarta.apache.org> For additional
> > commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message