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

Pages: 1-

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:22 ID:r3l/lAht

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

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" );
    }
}

Name: Anonymous 2007-04-28 19:33 ID:GNaA7Mc8

WelcomeToJavaWhereEveryFuckingThingHaveTheLengthOfABestSellingNovelAtBest

And i have to take a fucking java course. It hurts, especially as the teacher is 'look how wonderful and easy and good this is!'

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

>>3
Sorry, but I don't understand.

>>4
My teacher says it's 'elegant', but he grew programming LISP

Name: Anonymous 2007-04-28 20:11 ID:m5saG91R

``if (!(zong[k] == A) || (zong[k] == B) || (zong[k] == C))``
better. dunno why.

Name: Anonymous 2007-04-28 20:22 ID:sO3981t4

Holy shit people, it's called strpbrk.

char *pos = strpbrk(zong, "ABC");
After the call to strpbrk, *pos will be either '\0' (good, the entire string was A's, B's, and C's) or the first character in the string that wasn't one of those characters.

If Java doesn't have anything even remotely similar to this, Java is a shitty fucking language and deserves immediate death.

Name: Anonymous 2007-04-28 20:24 ID:sO3981t4

>>7
Disregard, cocks, etc.
s/strpbrk/strspn/g

Name: Anonymous 2007-04-28 20:25 ID:sO3981t4

oh and, size_t pos = zong + strspn(etc.)
.... fuckit, read the libc programmers manual, I'm not sober.

Name: Anonymous 2007-04-28 20:50 ID:3H5UrepC

Java is a shitty fucking language and deserves immediate death.
Sounds about right

Name: Anonymous 2007-04-28 21:19 ID:vTs116D9

>>7
Using library functions instead of rewriting them? Your code is not ENTERPRISE

Name: Anonymous 2007-04-29 6:44 ID:Heaven

for (char c: zong)

Name: Anonymous 2007-04-29 18:32 ID:XKxLXFq4

Quoting for truth:
Java is a shitty fucking language and deserves immediate death.

Name: Anonymous 2007-04-30 1:53 ID:LCsVhMJm


case takeWhile (`elem` "ABC") zong of
    [] -> zong
    _  -> error "error"

Name: Anonymous 2007-04-30 3:37 ID:TAy5KpNy

java is a-ok after you've spent endless hours using it and actually learned it at the end.

Name: Anonymous 2007-04-30 12:39 ID:mMCjmS/v

I still haven't figured out a way. can anybody help me?

Name: Anonymous 2007-04-30 13:25 ID:SGERIZPh

>>14
lol go back to bed

Name: Anonymous 2007-04-30 14:05 ID:Heaven

for(char c: zong) if(c!='A' && c!='B' && c!='C') throw new Exception("cocks");

Name: Anonymous 2007-05-01 0:01 ID:LZDx1mI0

>>12

!! I got it, that's the new foreach thing!! 0___________________________________________________________________________________________o

many thanks, /prog/

Name: Anonymous 2007-05-01 4:34 ID:vO+ZfF9N

>>19
"new" LOL

Name: Anonymous 2009-03-06 8:37


The left Shift to   select and modal   selection blows too   when you want   as long as   he is happy   just be sure   that other stuff   it depends on   Y we should   meet up some   documentation in a   concise elegant and   is overly complex   and useless like   C try javascript.

Name: Anonymous 2009-07-21 2:08

real real who real real men men things do    things . pro other pro a versions other  quality quality quality  Javascript secure. quality    printf("%s",q[i^=1]);  {"''", main()

Name: Anonymous 2010-11-15 17:37

Name: Anonymous 2011-02-04 17:28

Name: Sgt.Kabu寅퉥kiman셸앩 2012-05-29 1:00

Bringing /prog/ back to its people
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy

Name: Anonymous 2013-08-31 17:33


I'm a cat. My girl doesn't like it when I purr, and always complains about my hairs in her bed.

Name: Anonymous 2013-08-31 19:04


The new fad teen diet: getting cancer. Has our obsession with skinniness gone too far and driven our children off the deep end? Our reliable sources have reported that many overweight teens spend hours in front of special cylindrical chambers that bombard them with radiation. This process is designed to give them cancer that will ideally eat away all of their fat."

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