Ad
  • Custom User Avatar

    Can someone explain me this code ?

  • Custom User Avatar

    can someone explain me the following error message? don^t understand it.

    xpected exception: java.lang.Exception
    Stack Trace

    java.lang.AssertionError: Expected exception: java.lang.Exception
    at org.junit.internal.runners.statements.ExpectException.evaluate(ExpectException.java:34)
    at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
    at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
    at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
    at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
    at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
    at org.junit.vintage.engine.execution.RunnerExecutor.execute(RunnerExecutor.java:42)
    at org.junit.vintage.engine.VintageTestEngine.executeAllChildren(VintageTestEngine.java:80)
    at org.junit.vintage.engine.VintageTestEngine.execute(VintageTestEngine.java:72)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:107)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:54)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52)
    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:114)
    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:86)
    at org.junit.platform.launcher.core.DefaultLauncherSession$DelegatingLauncher.execute(DefaultLauncherSession.java:86)
    at org.junit.platform.launcher.core.SessionPerRequestLauncher.execute(SessionPerRequestLauncher.java:53)
    at com.codewars.junit5.TestRunner.executeTests(TestRunner.java:64)
    at com.codewars.junit5.TestRunner.lambda$execute$0(TestRunner.java:56)
    at com.codewars.junit5.TestRunner.callWithCustomClassLoader(TestRunner.java:147)
    at com.codewars.junit5.TestRunner.execute(TestRunner.java:56)
    at com.codewars.junit5.TestRunner.main(TestRunner.java:44)

  • Custom User Avatar

    what is the advantage of using a Set ? and not something from the List interface.

  • Custom User Avatar

    Can the List you should return contain more than two indexes? if more than 1 combination equals the target number.

  • Custom User Avatar

    i did it in the same way, but i passed all the test

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    import java.util.*;
    class Solution {

    public static String isSortedAndHow(int[] array) {
    int max = array[0];
    for(int i = 0; i < array.length; i++) {
    if(max < array[i]) {
    max = array[i];
    }

    }
    
     
    if(max == array[array.length - 1]) {
      return "yes, ascending";
    

    }

    if( max == array[0]) {
      return "yes, descending"; 
    }
    return "no"; 
    

    }

    }
    it wont pass Test3 should return no but was yes, ascending
    can someone help out??