Java中case使用示例,Javacase使用示例,switch([vari
分享于 点击 39521 次 点评:6
Java中case使用示例,Javacase使用示例,switch([vari
switch([variable]) { case [int or ch]: [code] break; case [int or ch]: [code] break; case [int or ch]: [code] break; case [int or ch]: [code] break; }//举例int count; switch(count) { case 0: g.setColor(Color.yellow); g.fillOval(50,50,100,100); g.setColor(Color.red); g.fillOval(115,75,10,10); g.fillOval(75,75,10,10); g.fillOval(75,115,10,10); g.fillOval(115,115,10,10); break; case 1: g.setColor(Color.yellow); g.fillArc(50,50,100,100,0,270); g.setColor(Color.red); g.fillOval(115,75,10,10); g.fillOval(75,75,10,10); g.fillOval(75,115,10,10); break; case 2: g.setColor(Color.yellow); g.fillArc(50,50,100,100,0,180); g.setColor(Color.red); g.fillOval(115,75,10,10); g.fillOval(75,75,10,10); break; case 3: g.setColor(Color.yellow); g.fillArc(50,50,100,100,0,90); g.setColor(Color.red); g.fillOval(115,75,10,10); break; }
用户点评