Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Storing a very large string array or string?

I have a large list of 1600 autocomplete options for my textbox in Visual Studio. What is the best way to add those options to the textbox custom autocomplete list?

I currently have all the settings in my text editor separated by semicolons. Should I just copy that into VS as a string as add it to the list by splitting it into an array with the semicolons as the delimiter? Would it be better to convert the code into a string array like: new string[x]{"setting1","setting2","setting3","setting4"}... etc? Should I store it in the application settings or in a new file and put it as a resource? Are all these essentially the same thing?

like image 821
mowwwalker Avatar asked Jan 04 '12 05:01

mowwwalker


People also ask

Can you store strings in an array?

Answer: Yes. Just like arrays can hold other data types like char, int, float, arrays can also hold strings. In this case, the array becomes an array of 'array of characters' as the string can be viewed as a sequence or array of characters.

How long can a string array be?

Therefore, the maximum length of String in Java is 0 to 2147483647.

How is an array of strings stored in memory?

Strings are stored on the heap area in a separate memory location known as String Constant pool. String constant pool: It is a separate block of memory where all the String variables are held. String str1 = "Hello"; directly, then JVM creates a String object with the given value in a String constant pool.


1 Answers

With a list that large, my primary concern (other than speed) would primarily be maintainability.

If it were my application, I would store this in a file and either read that file in at app startup or store it as an embedded resource depending on the need to customize or update once deployed.

In fact, I would start with a standalone file until I understood the pace of change on the file, if any.

like image 61
competent_tech Avatar answered Oct 22 '22 04:10

competent_tech