4D array of references to strings

I'm fairly new to Java and I need a little help with a very specific problem...

I need to create a 4D array datatype with the last dimension holding strings. In Turbo pascal it might look like

joe : array[1..7,1..6,1..60,1..168] of String;

In fact, these are the exact dimensions I need but that doesn't really matter. Now, knowing that this question is too easy for all you guys, I have something else that I need help with.

Instead of just holding strings, I'd like this structure to hold references to strings in order to save memory. The reason is this... Throughout this whole array, there might only be as few as 100 distinct strings but they all get copied a couple hundred times so that they each fill 100 array elements at a time. Instead of duplicating the strings in memory every time I copy them into a new array element, I'd like to just store references to those strings. That way, each element of the array will take 4 bytes (or whatever a Java reference takes) instead of 30 odd bytes for the string, hence saving mondo memory.

So, here's what I need...

I need a class with a constructor that when instantiated, will create this 4D array of whatever data type is necessary to store references to strings. I'd like to be able to specify the dimensions by passing parameters, if that's ok... So, this class would be instantiated like this, I think...

4dArray joe = new 4dArray(5,6,30,168); //how do I access the individual elements?

I'll also need a few basic instructions on how references work in Java since I haven't been able to find any information on them... Even in the Sunsoft Tutorial (am I blind?). If somebody knows of another good URL where one can get good info on Java, I'd be very much appreciative. I'm familiar with references in PERL ( \variable-name ) and pointers in Pascal but I don't know if that's how Java works at all. Once I have that information, I think I'll be able to write my methods, etc. Oh, if you need a length for the strings, set them at 30.

------
If you run it alone (java D4Array) you can see the small test program works.
The interface is simple. The class I think you should use (as in the small example) is the Hashtable. the average access complexity is a bit higher then o(1). You store the actual objects (note that this data structure is generic - not only for strings) in the hash and therfore you can check in o(1) time is this object (String for you) was used before. I'll add a comment about the references later.

colind, I must add that if you refer to a location in the array that wasn't assigned with a value, you will get null.
Now, regarding your question, java doesn't have references at all. Java only deals with pointers, and the pointers can only be pointers to classes (not to the primitive types as possible in C,C++). So you can achieve the reference effect by using the pointer of a class. Also, the pointers functionality is different than in C,C++. The 'dangerous' powers that the pointers had (example - wild casting between pointer types, pointer arithmetic etc.) doesn't exist in java, and other new features were added. In general - you haven't found the information because its not there. What you do have are pointers. If you know pointers in C its a good start. In the small example above, none of the structures (not the Hashtable nor the 4D array) really hold the actual data. Both of them holds Object pointers (Object the the most basic class in java) to the actual object that can be found somewhere in the JVM allocated memory. By the way, the JVM countsthe number of live pointers to every object, and when its 0, this object is a candidate of being deleted (garbage collection).

Does this mean that when I want to extract an element from the array structure, I have to specify what kind of object it is? Is this the case all the time? For instance, say I was storing integers in the array, would I do an addition like:

Joe = 5 + (int)thetextclass.getElement(3,2,3,4);

??

Also, you said that all unassigned values are null... Is there a way that I could test for that??? I'll give you the context of what I mean...

Assume I have two arrays of strings with dimension [200]. 30 elements in each array are filled with strings or pointers or whatever. I want to take array1 and copy every non-null element into the corresponding element of Array2 and then test array2 to see if it contains 60 non-null elements or whether it contains less than 60 (because some were overwritten). When I make the method to do this, can I do something like...

The (String) cast wasn't necessary at that case but I did it deliberately so that you can see how to use this data structure. The thing is that since I did this data structure general, any class can be stored is it (all classes in java are derived from the class Object) so when you get an element you have to cast it to the type that it is. However, in java all the inheritance data is stored in the pointer type (the new features I reminded above) so you can query an object about its type for example:

This feature is almost unique to java (SmallTalk has it to) and a most powerful one. By he way, the example that you gave will actually wont work because the int type cant have pointer to it (as all other basic types - I monitored it). You could have use the Integer (or is it Int?) class instead. The Integer class that wraps an int value in a class. That is somewhat confusing at the beginning but quite easy once you get the idea of the java thing.

Regarding your other question, well, the example you gave was almost right. The right version would be:

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…

Viewers will learn one way to get user input in Java.
Introduce the Scanner object:
Declare the variable that stores the user input:
An example prompting the user for input:
Methods you need to invoke in order to properly get user input:

How to fix incompatible JVM issue while installing Eclipse
While installing Eclipse in windows, got one error like above and unable to proceed with the installation.
This video describes how to successfully install Eclipse.
How to solve incompa…