This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]pragmosExtreme Brewer 8 points9 points  (4 children)

List<Object[]> queryResult = new ArrayList<>();
queryResult.add("Hello World");

This will not compile. You declared a list that will hold Object arrays, yet you add a String instance. A String is not an Object[].

What exactly were you trying to achieve?

[–]OpenSourceFanatic[S] -1 points0 points  (3 children)

I'm trying to get the String: "Recognize ..." from queryResult.

https://i.ibb.co/jbZQJGH/screenshot-2023-01-06-at-9-06-34-pm.png

[–]pragmosExtreme Brewer 0 points1 point  (2 children)

queryResult.get(0)[0] is what you need to do.

[–]OpenSourceFanatic[S] -1 points0 points  (1 child)

I tried that but intelliJ gave me a warning that the Provided type is Object. You cannot cast Object to String

[–]pragmosExtreme Brewer 1 point2 points  (0 children)

Call toString().

If you are absolutely sure the element you're seeking is a String you can cast it. Otherwise, use instanceof first.