I have a simple function like:
private void function(LinkedList<String> a, LinkedList<String> b)
We already know that if those arguments were only string, passing values inline would be easy, like:
function("aaa", "bbb")
But is there a way to pass inline a LinkedList?
I tried with:
function(["A", "B", "C"], ["A", "B"])
but it does not work.
Change the type from LinkedList
to the List
interface, and then you can use Arrays.asList(T...)
like
function(Arrays.asList("A", "B", "C"), Arrays.asList("A", "B"))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With