The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
February 2002

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

just add default after the last case

Posted by ping203 on February 12, 2002 at 4:20 PM

try the following, I've modified a little to make the codes shorter.

switch(aeiouAEIOU) {
case 'a':case 'A':
aCount = aCount + 1;
break;
case 'e':case 'E':
eCount = eCount + 1;
break;
case 'i':case 'I':
iCount = iCount + 1;
break;
case 'o':case 'O':
oCount = oCount + 1;
break;
case 'u':case 'U':
uCount = uCount + 1;
break;
default: //just add default after the last case
otherCount++ //if the char is not aeiouAEIOU, then
break; //otherCount++ will be executed
}





Replies:
  • It doesn't work Patti February 12, 2002 at 7:01 PM (1)
    • code ping203 February 13, 2002 at 12:58 PM (0)

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us