今天看到代码: public static NativeProcess executeCmd(String[] cmd, String[] env, String dirName) {
Runtime rt = Runtime.getRuntime();
File dir = null;
Process process = null; /* Check if one of the arguments in the array is not null by chance... */
for (String arg : cmd) {
if (arg == null) {
return null;
}
}粗体的那句不明白这是什么用法,请高手解答, 谢谢!
Runtime rt = Runtime.getRuntime();
File dir = null;
Process process = null; /* Check if one of the arguments in the array is not null by chance... */
for (String arg : cmd) {
if (arg == null) {
return null;
}
}粗体的那句不明白这是什么用法,请高手解答, 谢谢!
遍历这个cmd数组啊.增强for循环.不会不知道吧.
真不知道lz是什么意思
就是
for(int i=0;i<cmd.length;i++){}
是java 5的新特性
for(type variable : array){
body
}
还原以前的版本的形式为
for(int i=0;i<array.length;i++){
type variable=array[i];
body
}