java help please. very short question

Discussion in 'OT Technology' started by nietsni3, Apr 21, 2005.

  1. nietsni3

    nietsni3 Guest

    Code:
    switch (i)
      		{
          		    	case 0: int[] s = {1,0,1,1,1,1,1}; break;
          		    	case 1: s = {0,0,0,0,0,1,1}; break;
          		    	case 2: s = {1,1,1,0,1,1,0}; break;
          		    	case 3: s = {1,1,1,0,0,1,1}; break;
          		    	case 4: s = {0,1,0,1,0,1,1}; break;
          		    	case 5: s = {1,1,1,1,0,0,1}; break;
          		    	case 6: s = {1,0,1,1,1,0,1}; break;
          		    	case 7: s = {1,0,0,0,0,1,1}; break;
          		    	case 8: s = {1,1,1,1,1,1,1}; break;
          		    	case 9: s = {1,1,1,1,0,1,1}; break;
      		}
    when i compile, it said
    Code:
     I:\HW\csci 112\Lab7\WelcomeApplet.java:19: illegal start of expression
         		    	case 1: s = {0,0,0,0,0,1,1}; break;
     												 ^
     I:\HW\csci 112\Lab7\WelcomeApplet.java:20: illegal start of expression
         		    	case 2: s = {1,1,1,0,1,1,0}; break;
     												 ^
     I:\HW\csci 112\Lab7\WelcomeApplet.java:21: illegal start of expression
         		    	case 3: s = {1,1,1,0,0,1,1}; break;
     												 ^
     I:\HW\csci 112\Lab7\WelcomeApplet.java:22: illegal start of expression
         		    	case 4: s = {0,1,0,1,0,1,1}; break;
     												 ^
     I:\HW\csci 112\Lab7\WelcomeApplet.java:23: illegal start of expression
         		    	case 5: s = {1,1,1,1,0,0,1}; break;
     												 ^
     I:\HW\csci 112\Lab7\WelcomeApplet.java:24: illegal start of expression
         		    	case 6: s = {1,0,1,1,1,0,1}; break;
     												 ^
     I:\HW\csci 112\Lab7\WelcomeApplet.java:25: illegal start of expression
         		    	case 7: s = {1,0,0,0,0,1,1}; break;
     												 ^
     I:\HW\csci 112\Lab7\WelcomeApplet.java:26: illegal start of expression
         		    	case 8: s = {1,1,1,1,1,1,1}; break;
     												 ^
     I:\HW\csci 112\Lab7\WelcomeApplet.java:27: illegal start of expression
         		    	case 9: s = {1,1,1,1,0,1,1}; break;
     												 ^
     9 errors
    in the error message, the ^ was right underneath the {. not liek how it appears here
    how can that be illegal? thanks
     
  2. Joe_Cool

    Joe_Cool Never trust a woman or a government. Moderator

    Joined:
    Jun 30, 2003
    Messages:
    299,206
    Likes Received:
    517
    Don't put your array declaration inside the switch statement. Do it like this:


    int[] s;
    switch (i)
    {
    case 0: s = {1,0,1,1,1,1,1}; break;
    case 1: s = {0,0,0,0,0,1,1}; break;
    case 2: s = {1,1,1,0,1,1,0}; break;
    case 3: s = {1,1,1,0,0,1,1}; break;
    case 4: s = {0,1,0,1,0,1,1}; break;
    case 5: s = {1,1,1,1,0,0,1}; break;
    case 6: s = {1,0,1,1,1,0,1}; break;
    case 7: s = {1,0,0,0,0,1,1}; break;
    case 8: s = {1,1,1,1,1,1,1}; break;
    case 9: s = {1,1,1,1,0,1,1}; break;
    }
     

Share This Page