struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Graham" <dgraham1...@hotmail.com>
Subject RE: [OT] Java Trivia
Date Thu, 12 Jun 2003 14:43:22 GMT
>Here's my code - it compiles just fine.  Note the string.length in the 
>for{}
>and the string.length() in the if{}:

I'm sure it does but not because you magically found a way to reference 
string.length.  Look at your code more closely, you're using an array not a 
String.

David


>
>test = st.nextToken();
>if( test.equals( " " )) { return false; }
>
>   for( int i = 0; i < months.length; i++ ) {
>
>     if( test.equals( months[ i ] )){
>       month = true;
>       break;
>     }
>   }
>if( !month ) { return false; }
>   test = st.nextToken();
>
>   if( test.length() > 3 || test.length() < 2 ) {
>     return false;
>
>   } else {
>     StringTokenizer token = new StringTokenizer( test, "," );
>
>     while( token.hasMoreTokens() ) {
>       int i = 0;
>       if( !Character.isDigit( token.nextToken().charAt( i ))) { return
>false; }
>       i++;
>   }
>}
>
>-----Original Message-----
>From: Jarnot Voytek Contr AU HQ/SC [mailto:Voytek.Jarnot@MAXWELL.AF.MIL]
>Sent: Thursday, June 12, 2003 10:02 AM
>To: 'Struts Users Mailing List'
>Subject: RE: [OT] Java Trivia
>
>
>for( int i = 0; i < string.length; i++ ) {}
>
>doesn't compile for me...
>
>--
>Voytek Jarnot
>Quidquid latine dictum sit, altum viditur.
>
>
> > -----Original Message-----
> > From: Mark Galbreath [mailto:mark_galbreath@qat.com]
> > Sent: Thursday, June 12, 2003 8:46 AM
> > To: 'Struts Users Mailing List'
> > Subject: [OT] Java Trivia
> >
> >
> > Anybody know why the length of a String is a property of the
> > String when
> > used as a logical qualifier in a for{} block but a function
> > of the String in
> > a conditional if{} statement?
> >
> > for( int i = 0; i < string.length; i++ ) {}
> >
> > if( string.length() != 4 ) {}
> >
> >
> > Mark
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-user-help@jakarta.apache.org
> >
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: struts-user-help@jakarta.apache.org
>

_________________________________________________________________
Help STOP SPAM with the new MSN 8 and get 2 months FREE*  
http://join.msn.com/?page=features/junkmail


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Mime
View raw message