2DWorlds Forums

Full Version: I found this interesting (Java)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
A multidimensional array!

In the Java programming language, a multidimensional array is simply an array whose components are themselves arrays.

[lua]
class MultiDimArrayDemo {
public static void main(String[] args) {
String[][] names = {
{"Mr. ", "Mrs. ", "Ms. "},
{"Smith", "Jones"}
};
// Mr. Smith
System.out.println(names[0][0] +
names[1][0]);
// Ms. Jones
System.out.println(names[0][2] +
names[1][1]);
}
}
[/lua]
Lua does this too, with tables. It's awesome for semi-advanced projects. It really shortens up long lines of messy code.
It's the same in most languages. Useful for lots of things.