2-D array vs string 1-D array

why do we use 2-d arrays of characters instead of 1-D arrays of strings. For ex…if we want to store name we can use 1-D arrays of string and store them. But i see people prefer to use 2-d array of characters instead of 1-D string …why is that?

If you are passing this to any functions then its always a better choice to choose character 2-d array than choosing arrays of strings but if you use it carefully both will work .
Difficults comes when you are Java developers . Since Strings are immutable in Java if you store password as plain text it will be available in memory until Garbage collector clears it and since String are used in String pool for reusability there is pretty high chance that it will be remain in memory for long duration, which pose a security threat.
For more info -->> https://javarevisited.blogspot.com/2012/03/why-character-array-is-better-than.html

1 Like

okay…i got it…but why do people refer 2-d array of character as string …technically it’s wrong right?
and one more do we even use string array?

Yess we can use array of strings !