Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Need help in Java char[]...

Name: Anonymous 2007-04-28 19:19 ID:r3l/lAht

Okay guys... I have a char[] suposely made of A's, B's and C's...

If I find a character that isn't one of those, I want it to throw an exception and leave.

how do I do it?

char[] zong = {A,L,C,B,}

for (int k = 0; k < zong.length; k++ ) {
if ((zong[k] != A) && (zong[k] != B) && (zong[k] != C)) {
throw new Exception("exit");
}
}

Is this it?

thanks, /prog/

Name: Anonymous 2007-04-28 19:30 ID:APkOGyVx

SingleCharacterFactory scfCharacters = new SingleCharacterFactory( new SingleCharacter( "A", 1 ), new SingleCharacter( "L", 1 ), new SingleCharacter( "C", 1 ), new SingleCharacter( "B", 1 ) );

for( SingleCharacter node = scfCharacters.firstChild; node; node = node.nextSibling )
{
    if ( node.getInstanceCharacter().equals( new SingleCharacter( "A", 1 ) )
      || node.getInstanceCharacter().equals( new SingleCharacter( "B", 1 ) )
      || node.getInstanceCharacter().equals( new SingleCharacter( "C", 1 ) ) )
    {
        throw new SingleCharacterException( "exit" );
    }
}

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List