I want to define an array of strings but I don’t know the number of strings I’ll need to store in it. Can I define such an array, and how can I insert strings into it?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Better use List like this:
Later if you need array of names, call:
If you have to use an array of strings then you should know the size upfront. If you don’t know the size, then you can initialize array of some default length (say 10).
The things that you have to do are:
So its better to use list rather then doing all this stuff by yourself