Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between String[] and Array<String>

Tags:

java

arrays

types

I'm new to Java and I can't figure out what the difference between String[] and Array<String> is. And how do I actually count how many entries a String[] Array has? Thanks!

like image 814
Force Avatar asked Jan 25 '26 07:01

Force


2 Answers

And how do I actually count how many entries a String[] Array has?

if(strArr !=null){
  strArr.length;
}
like image 178
jmj Avatar answered Jan 26 '26 19:01

jmj


String[] - is an array

Array - is a part of reflection API which you shouldn't bother about until you get more experience in java.

String[] a = new String[length]; - is a proper instantiation of array

a.length - returns length of the array

like image 41
bezmax Avatar answered Jan 26 '26 21:01

bezmax



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!