# OrtSession.Result (onnxruntime 1.15.0 API)

Package ai.onnxruntime

## Class OrtSession.Result

- java.lang.Object
- - ai.onnxruntime.OrtSession.Result

All Implemented Interfaces:
  `java.lang.AutoCloseable`, `java.lang.Iterable<java.util.Map.Entry<java.lang.String,​OnnxValue>>`

Enclosing class:
  OrtSession

    public static class OrtSession.Result
    extends java.lang.Object
    implements java.lang.AutoCloseable, java.lang.Iterable<java.util.Map.Entry<java.lang.String,​OnnxValue>>

An `AutoCloseable` wrapper around a `Map` containing `OnnxValue`s.

When this is closed it closes all the `OnnxValue`s inside it. If you maintain a reference to a value after this object has been closed it will throw an `IllegalStateException` upon access.

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `close()`
`OnnxValue` `get​(int index)` Gets the value from the container at the specified index.
`java.util.Optional<OnnxValue>` `get​(java.lang.String key)` Gets the value from the container assuming it's not been closed.
`java.util.Iterator<java.util.Map.Entry<java.lang.String,​OnnxValue>>` `iterator()`
`int` `size()` Returns the number of outputs in this Result.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface java.lang.Iterable

`forEach, spliterator`

### Method Detail

#### close

    public void close()

Specified by:
  `close` in interface `java.lang.AutoCloseable`

#### iterator

    public java.util.Iterator<java.util.Map.Entry<java.lang.String,​OnnxValue>> iterator()

Specified by:
  `iterator` in interface `java.lang.Iterable<java.util.Map.Entry<java.lang.String,​OnnxValue>>`

#### get

    public OnnxValue get​(int index)

Gets the value from the container at the specified index.

Throws `IllegalStateException` if the container has been closed, and `IndexOutOfBoundsException` if the index is invalid.

Parameters:
  `index` - The index to lookup.
Returns:
  The value at the index.

#### size

    public int size()

Returns the number of outputs in this Result.

Returns:
  The number of outputs.

#### get

    public java.util.Optional<OnnxValue> get​(java.lang.String key)

Gets the value from the container assuming it's not been closed.

Throws `IllegalStateException` if the container has been closed.

Parameters:
  `key` - The key to lookup.
Returns:
  Optional.of the value if it exists.