The for loops work just fine! The issue arises at temp part... "number(k) now found". how to solve this.
package com.codegym.task.task06.task0622;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.*;
import java.util.*;
/*
Ascending numbers
*/
public class Solution {
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
ArrayList<Integer> number = new ArrayList<Integer>(5);
for (int i=0; i<5; i++){
String num = reader.readLine();
int Num = Integer.parseInt(num);
number.add(Num) ;
}
ArrayList<Integer> temp = new ArrayList<Integer>(5);
for(int k = 0;k <number.size(); k++) {
for(int j = 1; j<number.size(); j++) {
if (number.get(k) < number.get(j))
temp = number(k);
number(k) = number(j);
number(j) = temp;
}
}
Arrays.sort(numbers);
for(int j = 0; j<numbers.length; j++){
System.out.println(Arrays.toString(list));
}//write your code here
System.out.println(number);
}
}