I have 2 classes going like this:

```
public class Seat extends Moviefiable {

        private int number;
        private Hall hall;

        public Seat(int id, boolean active, int number, Hall hall) {
            super(id, active);
            this.number = number;
            this.hall = hall;
        }

        public Seat() {this(-1, false, -1, null);}

        public static Seat getById(int idSeat) throws SQLException {
            Seat seat = SeatDAO.getById(idSeat);
            return seat;
        }
}

public class Ticket extends Moviefiable {

private Projection projection;
private Seat seat;
private LocalDateTime purchasingDate;
private User user;

public Ticket(int id, boolean active, Projection projection, Seat seat, LocalDateTime purchasingDate, User user) {
    super(id, active);
    this.projection = projection;
    this.seat = seat;
    this.purchasingDate = purchasingDate;
    this.user = user;
}

public Ticket() {this(-1, false, null, null, null, null);}

```

Now, I need to create two or more `Tickets`, depending how many tickets `loggedInUser` chooses. From my `JSP` page, I'll get something like this:

```
String uri = request.getQueryString(); //uri looks like this: seats=2&seats=3

```

I want to create two `Ticket` objects for two `Seat` objects. In `uri` string, chars 2 and 3 are primary keys for seats.

The idea is to use Java streams to perform splitting and creating objects. This is I have so far.

```
ArrayList<Ticket> newTicketsForSeats = Stream.of(uri.split("&"))
                   .map(s -> s.split("seats=")[1])
                   //.flatMap(Arrays::stream)
                   .mapToInt(Integer::valueOf)
                   .mapToObj(s -> {
                    try {
                        return new Ticket(-1, true, projection, SeatDAO.getById(s), 
                                 LocalDateTime.now(), loggedInUser);
                    } catch (SQLException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                        return null;
                    }
                })
                   .collect(Collectors.toCollection(ArrayList::new));

```

When I made a test, like this to see the output I'm getting:

```
Stream.of(uri.split("&"))
    .map(s -> s.split("seats=")[1])
    .mapToInt(Integer::valueOf)
    .forEach(System.out::println); //2 3

```

Which is okey. But when I run code above, I got:

```
java.lang.ArrayIndexOutOfBoundsException: 1
at servlets.ConfirmPurchaseServlet.lambda$0(ConfirmPurchaseServlet.java:62)
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
at java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472)
at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)

```

`projection` is also object, which I obtained, this is just reference, it is elsewhere in servlet. `loggedInUser` I got from session. I'm newbie regarding Java streams, any additional explanation would be excellent. 

I get that `map()` requires `IntUnaryOperator` lambda expression, something like this:

```
s -> s * 10

```

I don't know how to "map" from int (primary key for Seat) to `Seat` object.

Cheers.