Output not released



  • Decide nothing. Not Stop! Well, why don't you explain the results to the console?

    import static java.lang.System.out;
    import java.util.Arrays;
    

    class Ideone{
    public static void main (String[] args){
    int[] arr={1,2,3,4,5,6,7};
    task(arr);
    }
    public static String task(int[] array) {
    if (array.length <= 2) {
    throw new IllegalArgumentException("Нечего менять");
    }
    for (int i = 1; i < array.length; i += 2) {
    array[i] = array[i] + array[i + 1];
    array[i + 1] = array[i] - array[i + 1];
    array[i] = array[i] - array[i + 1];
    }
    return ("Массив:"+Arrays.toString(array));
    }}

    (Transition: In a given single-dimensional mass, change the surroundings on the right spots with components on the wrong side)



  • Method task(arr); Even though he returns the line, he doesn't turn it off. It's worth writing. System.out.println(task(arr));Then the console will take the return method task() line.




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2