来自一个软高理论考试学员的反馈

有学员反馈说, air max pas cher 考试时遇到一个考数组的题目,使用平时练习的方法进行不下去, Adidas Zx Flux Femme Leopard 后来发现,平时练习的数组代码如下: public class Largest { public int largest (int[] data) { int maxdata = 0; for (int i = 0; i maxdata) maxdata = data[i]; } return maxdata; } } 相关的Junit代码如下: import static org.junit.Assert.*; import org.junit.Test; public class LargestTest { @Test public void testLargest() { int[] a = {7,8,9}; Largest L1 = new Largest(); assertTrue(L1.largest(a)==9); } } 考试时他遇到的代码中,largest方法前面多了个static, nike air jordan 13 homme 所以有提示。 nike italia 接着我在eclipse.exe中将代码重现,发现用原来方法时, Asics Homme 会有警告,内容如下: The static method largest(int[]) from the type Largest should be accessed in a static way 原来是引用静态方法的时候,直接用类引用就可以了。 louboutin 不需要通过对象去调用, New Balance 530 femme 所以不需要先去Largest L1 = new Largest();直接使用Largest. largest(a)就可以了。在这种情况下, ugg soldes Junit代码变为如下内容: import static org.junit.Assert.*; import org.junit.Test; public class LargestTest { @Test public void testLargest() { int[] a = {7,8,9}; assertTrue(Largest.

This entry was posted in 计算机软件, 软件测试 and tagged , . Bookmark the permalink.