Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.util.ArrayList;

import java.util.List;

public class Main {
    public static void getBJ() {
        List<Integer> l1 = new ArrayList<Integer>();
        l1.add(1);
        l1.add(2);
        l1.add(3);
        l1.add(4);
        List<Integer> l = new ArrayList<Integer>();
        for (Integer item : l1) {
            if (item == 2 || item == 7) {
                l.add(item);
            }
        }
        l1.removeAll(l);
        l.addAll(l1);
        System.out.println(l);
    }
}