-
-
Save corningsun/1afdd69da58d3ed7888ce022be76d4da to your computer and use it in GitHub Desktop.
v2ex-Reply39
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.corning.v2; | |
public class Reply39 { | |
public static void main(String[] args) throws Exception { | |
String[] wA = new String[]{"0", "0", "0", "0", "0", "0", "0"}; | |
new Reply39().hello("0", wA[0], wA[1], wA[2], wA[3], wA[4], wA[5], wA[6]); | |
// hello | |
new Reply39().hello("3", wA[0], wA[1], wA[2], wA[3], wA[4], wA[5], wA[6]); | |
// Exception in thread "main" java.lang.Exception: 设置项目参数非法! | |
} | |
public void hello(String open, String w1, String w2, String w3, String w4, String w5, String w6, String w7) throws Exception { | |
if (!isZeroOrOne(open) | |
&& isZeroOrOne(w1) | |
&& isZeroOrOne(w2) | |
&& isZeroOrOne(w3) | |
&& isZeroOrOne(w4) | |
&& isZeroOrOne(w5) | |
&& isZeroOrOne(w6) | |
&& isZeroOrOne(w7) | |
) { | |
throw new Exception("设置项目参数非法!"); | |
} | |
System.out.println("hello"); | |
} | |
private boolean isZeroOrOne(String s) { | |
return "0".equals(s) || "1".equals(s); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment