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 String[] filterFloor(List<String> longRoomList, String buildingNumber, String prefix) {
        /**/
        if (longRoomList == null) {
            return null;
        }
        List<String> floor_info = new ArrayList<String>();
        for (int i = 0; i < longRoomList.size(); ++i) {
            String[] slice = longRoomList.get(i).split("-");
            if (slice.length == 4 && slice[0].equals(buildingNumber) && !floor_info.contains(prefix + slice[1])) {
                floor_info.add(prefix + slice[1]);
            }
        }
        return listToArray(floor_info);
    }

    public static String[] listToArray(List<String> l) {
        String[] a = new String[l.size()];
        for (int i = 0; i < l.size(); i++) {
            a[i] = l.get(i);
        }
        return a;
    }
}