% character in switch statement

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rainman33
    New Member
    • Oct 2007
    • 5

    #1

    % character in switch statement

    I've looked online and in my textbook, but can't find any explanations for what "wildcards" do in controlling expression parentheses. I have the following code:

    Code:
    1 	switch ( value % 2 )
    2 	{
    3 		case 0:
    4 			outputJTextField.setText( "Even Integer" );
    5
    6 		case 1:
    7 			outputJTextField.setText( "Odd Integer" );
    8 			break;
    9
    10 	} // end switch
    I can't figure out what the "%" does in my switch controlling expression. Can anyone please provide me with a list of wildcard characters that are recognized in Java switches, and their uses?

    Thanks.
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by rainman33
    I've looked online and in my textbook, but can't find any explanations for what "wildcards" do in controlling expression parentheses. I have the following code:

    Code:
    1 	switch ( value % 2 )
    2 	{
    3 		case 0:
    4 			outputJTextField.setText( "Even Integer" );
    5
    6 		case 1:
    7 			outputJTextField.setText( "Odd Integer" );
    8 			break;
    9
    10 	} // end switch
    I can't figure out what the "%" does in my switch controlling expression. Can anyone please provide me with a list of wildcard characters that are recognized in Java switches, and their uses?

    Thanks.
    % is not a wild card character. It is an operator. Google "% operator Java" and find out what it does.

    Comment

    • heat84
      New Member
      • Nov 2007
      • 118

      #3
      Perhaps understanding how the switch statement works can be of help to you.

      Comment

      Working...