<BlockSwitcher>
<Block name="Java">

```java
Amplify.DataStore.query(Post.class,
    queryMatches -> {
        if (queryMatches.hasNext()) {
            Log.i("MyAmplifyApp", "Successful query, found posts.");
        } else {
            Log.i("MyAmplifyApp", "Successful query, but no posts.");
        }
    },
    error -> Log.e("MyAmplifyApp",  "Error retrieving posts", error)
);
```

</Block>
<Block name="Kotlin - Callbacks">

```kotlin
Amplify.DataStore.query(Post::class.java,
    { matches ->
        if (matches.hasNext()) {
            Log.i("MyAmplifyApp", "Successful query, found posts.")
        } else {
            Log.i("MyAmplifyApp", "Successful query, but no posts.")
        }
    },
    { Log.e("MyAmplifyApp",  "Error retrieving posts", it) }
)
```

</Block>
<Block name="Kotlin - Coroutines">

```kotlin
Amplify.DataStore.query(Post::class)
    .catch { Log.e("MyAmplifyApp",  "Error retrieving posts", it) }
    .collect { Log.i("MyAmplifyApp", "Post retrieved successfully") }
```

</Block>
<Block name="RxJava">

```java
RxAmplify.DataStore.query(Post.class).subscribe(
    post -> Log.i("MyAmplifyApp", "Successful query, found post."),
    error -> Log.e("MyAmplifyApp",  "Error retrieving posts", error)
);
```

</Block>
</BlockSwitcher>
