Bubble sort using ArrayList (JAVA)

import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        //Declare list of ArrayList
        ArrayList<Integer> list = new ArrayList<Integer>();
        //count is the number of repetitions
        int count = 0;
        count = scanner.nextInt();
        //Store input value in list
        for (int i = 0; i < count; i++) {
         //Bubble sort of ArrayList
         for (int i = 0; i < list.size() - 1; i++) {
            for (int j = list.size() - 1; j > i; j--) {
                if (array.get(j - 1) > list.get(j)) {
                    int tmp = list.get(j - 1);
                    list.set(j -1, list.get(j));
                    list.set(j, tmp);
        //Extended for statement
        for(int a: list) {

Recommended Posts

Bubble sort using ArrayList (JAVA)
java bubble sort
Sort by multiple conditions using Java Stream
java selection sort
[java] sort in list
Sorting using java comparator
Java Japanese (Kanji) Sort
Scraping practice using Java ②
Scraping practice using Java ①
[Java] Sort ArrayList with elements of your own class
[Java] Sort the list using streams and lambda expressions
Try using RocksDB in Java
[Neta] Sleep Sort in Java
Try scraping using java [Notes]
java ArrayList, Vector, LinkedList comparison
Sort strings functionally with java
Using Mapper with Java (Spring)
I tried using Java REPL
[Java8] Sort int type array in descending order using stream
Using Docker from Java Gradle
[Java] Convert ArrayList to array
Sorting in ascending order in Java (bubble sort: simple exchange algorithm)
Java List Group, Sort, etc.
Make a rhombus using Java
Export issues using JIRA's Java API
Encrypt using RSA cryptography in Java
Upload a file using Java HttpURLConnection
Sort a List of Java objects
Try using Redis with Java (jar)
[Java] Boilerplate code elimination using Lombok
Handling of time zones using Java
Java basic learning content 2 (array / ArrayList)
Unexpected exception when using Java DateTimeFormatter
Save ArrayList using GSON on Android
Using Java with AWS Lambda-Eclipse Preparation
[Java] Boilerplate code elimination using Lombok 2
[Java] Try to implement using generics
[Java] Difference between array and ArrayList
HTTPS connection using tls1.2 in Java 6
I tried using JWT in Java
[Java] How to use List [ArrayList]
Html5 development with Java using TeaVM
Formatting an enum using formatter-maven-plugin (Java)
Deleting files using recursive processing [Java]
Summary of object-oriented programming using Java
Sample code using Minio from Java
Using proxy service with Java crawling
[Java] Convert array to ArrayList * Caution
Try using Hyperledger Iroha's Java SDK
[Java] Where did you try using java?
I tried using GoogleHttpClient of Java