[java] 2 questions

Started by
10 comments, last by Smoo 23 years, 10 months ago
Sure you can pass chars to a switch. I just made a sameple project confirming this. Heres the code:

#include

void main()
{
char letter = NULL;

cout << "Enter a letter." << endl;
cin >> letter;

switch(letter)
{
case ''a'': cout << "Hello" << endl; break;
case ''b'': cout << "Bye Bye" << endl; break;

default: cout << "I dont understand" << endl; break;
}
}

I think you can also pass strings and in the case part you would do this case "string": but i dont remember if i have ever done that or not.

-Snyper



=============================Where's the 'any' key?=============================
Advertisement
Not too shabby Snyper, but he''s doing his proggie in java

War doesn't determine who is right, war determines who is left.

This topic is closed to new replies.

Advertisement