我的源代码是这样的:
   public class 1
   {  
    public static void main(String[] args)
          {     int x,y;
                 x=12;
                 switch(x)
               {
                    case 1:
                    case 3:
                    case 5: y=1;break;
                    case 2:
                    case 4:
                    case 6: y=2;
                    default: y=3;
                }
                System.out.println("x的值:"+ x +" y的值:"+ y);
            }
    }
      在JCreator中编译后,它说有两个错误:
--------------------配置:            <--------------------
D:\1.java:1: 需要 <标识符>
 public class 1
              ^
D:\1.java:19: 需要 '{'
      
      ^
2 错误处理已完成。
            
麻烦大家帮我看看,我是初学者,不太懂,多谢了!

解决方案 »

  1.   

    public class 1? 
    class 1 是不是多了个空格?
    是的话写成class1或者class_1
      

  2.   

    to xizhiyao 类名中下划线_打头是可以的
      

  3.   

    public class Test1
       {  
        public static void main(String[] args)
              {     int x,y;
                     x=12;
                     switch(x)
                   {
                        case 1:
                        case 3:
                        case 5: y=1;break;
                        case 2:
                        case 4:
                        case 6: y=2;
                        default: y=3;
                    }
                    System.out.println("x的值:"+ x +" y的值:"+ y);
                }
        }
    这样就不会出错了
      

  4.   

    sorry哦
    lovelycatty(傻猫咪咪) 
    说的正确。
      

  5.   

    to xizhiyao,呵呵,只是提醒一下下。