Java参数传递 数组的使用
2010-10-14 10:58
375 查看
数组在函数定义中的使用格式(int[] OrphanCount)
调用的时候一般使用: int[] OrphanCountBefore = new int[2];
theCalledMethod(OrphanCountBefore);
这是公共函数
public void GetOrphanCount(int[] OrphanCount) {
int blockStoreOrphanCount = 0;
int buildEnvOrphanCount = 0;
String prePostText = "after";
try {
blockStoreOrphanCount = BlockStoreOrphanPurgeCache.getOrphanCount(true, ORPHAN_FILE, TestConstants.VERBOSE_ORPHAN_LOGGING);
OrphanCount[0] = blockStoreOrphanCount;
System.out.println("***** Found " + blockStoreOrphanCount + " blockstore orphans ");
buildEnvOrphanCount = BuildEnvironmentOrphanPurge.getOrphanCount(ORPHAN_FILE, TestConstants.VERBOSE_ORPHAN_LOGGING);
OrphanCount[1] = buildEnvOrphanCount;
System.out.println("***** Found " + buildEnvOrphanCount + " buildenv orphans ");
} catch (Exception e) { System.out.println("Still end up getting an exception up here"); e.printStackTrace();
}
}
这是调用者的代码
public void testWhileCondEvalsTrue() throws Exception {
int blockStoreOrphanCountBefore = 0;
int buildEnvOrphanCountBefore = 0;
int[] OrphanCountBefore = new int[2];
GetOrphanCount(OrphanCountBefore);
System.out.println("--------- Starting orphan data collection before running test case: ---------"+OrphanCountBefore[0]);
CreateWhileStep();
//int OrphanCountAfter[2];
int[] OrphanCountAfter = new int[2];
int blockStoreOrphanCountAfter = 0;
int buildEnvOrphanCountAfter = 0;
GetOrphanCount(OrphanCountAfter);
System.out.println("--------- Starting orphan data collection after running test case: ---------"+OrphanCountAfter[0]);
Assert.assertEquals(OrphanCountBefore[0],
OrphanCountAfter[0],"the blockStoreOrphanCount should be equal before and after run the test case");
}
调用的时候一般使用: int[] OrphanCountBefore = new int[2];
theCalledMethod(OrphanCountBefore);
这是公共函数
public void GetOrphanCount(int[] OrphanCount) {
int blockStoreOrphanCount = 0;
int buildEnvOrphanCount = 0;
String prePostText = "after";
try {
blockStoreOrphanCount = BlockStoreOrphanPurgeCache.getOrphanCount(true, ORPHAN_FILE, TestConstants.VERBOSE_ORPHAN_LOGGING);
OrphanCount[0] = blockStoreOrphanCount;
System.out.println("***** Found " + blockStoreOrphanCount + " blockstore orphans ");
buildEnvOrphanCount = BuildEnvironmentOrphanPurge.getOrphanCount(ORPHAN_FILE, TestConstants.VERBOSE_ORPHAN_LOGGING);
OrphanCount[1] = buildEnvOrphanCount;
System.out.println("***** Found " + buildEnvOrphanCount + " buildenv orphans ");
} catch (Exception e) { System.out.println("Still end up getting an exception up here"); e.printStackTrace();
}
}
这是调用者的代码
public void testWhileCondEvalsTrue() throws Exception {
int blockStoreOrphanCountBefore = 0;
int buildEnvOrphanCountBefore = 0;
int[] OrphanCountBefore = new int[2];
GetOrphanCount(OrphanCountBefore);
System.out.println("--------- Starting orphan data collection before running test case: ---------"+OrphanCountBefore[0]);
CreateWhileStep();
//int OrphanCountAfter[2];
int[] OrphanCountAfter = new int[2];
int blockStoreOrphanCountAfter = 0;
int buildEnvOrphanCountAfter = 0;
GetOrphanCount(OrphanCountAfter);
System.out.println("--------- Starting orphan data collection after running test case: ---------"+OrphanCountAfter[0]);
Assert.assertEquals(OrphanCountBefore[0],
OrphanCountAfter[0],"the blockStoreOrphanCount should be equal before and after run the test case");
}
相关文章推荐
- java学习笔记(四)----对象、数组作为参数传递,静态变量、静态方法的使用,内部类,使用文档注释
- 参数传递数组 接收 前端使用jquery向后台传递数组类型的参数,java后台直接通过list类型接收,会发现无法取到参数的情况。
- Java 客户端后台使用HTTP POST传递对象参数到服务器端
- C++和Java函数传递数组参数比较
- Perl函数参数中传递数组和引用的使用
- jni数组使用及将C的char数组传递给Java
- Oracle存储过程传入类似java中list、数组类型的参数并使用
- JAVA本地方法调用(2)数组参数传递
- 使用httpclient传递java参数调用http接口
- java后台接受web前台传递的数组参数
- C语言之使用指针数组传递参数
- java 实现往oracle存储过程中传递array数组类型的参数
- 使用uploadify3.2.1 formData传递其他参数到后台,JAVA后台获取参数方法
- json数组作为参数传递给java时候object问题
- java传递数组类型参数给oracle存储过程
- 关于将数组作为参数传递给函数的简单使用
- java 数组操作1.5后新特性--可变参数以及foreach使用
- 使用ASI传递post表单..参数是数组
- 看结果,测试?java中的String类 字符串拆分成字符串数组 判定邮箱地址 字符串比较 参数传递?
- SQLServer-存储过程中使用字符串和分隔符实现传递数组参数