Force
Force

Reputation: 6382

Difference between String[] and Array<String>

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!

Upvotes: 2

Views: 2454

Answers (3)

bezmax
bezmax

Reputation: 26132

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

Upvotes: 6

Jigar Joshi
Jigar Joshi

Reputation: 240900

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

if(strArr !=null){
  strArr.length;
}

Upvotes: 8

quant_dev
quant_dev

Reputation: 6231

Main difference: String[] is not resizable.

Length of String[]: use .length property.

Upvotes: 2

Related Questions