Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

C preprocessor equivalent in Java

Status
Not open for further replies.

Haazi2

Programmer
Aug 25, 2000
51
US
I have the following code in a c header file

#define MAX 10
#define HOSTS char* hostname[MAX][] = {"j40b", ""}

How do I code the equivalent in Java?
Thanks for any help in advance.
 
#define MAX 10
final static int MAX=10;

#define HOSTS char* hostname[MAX][] = {"j40b", ""}
Make a new class (Hosts), and put the host names in a hashtable or vector or string array, and initialize them in the constructor.

Good luck. Bye, Otto.
 
Sorry, the second line should read:

#define HOSTS char* hostname[MAX] = {"j40b", ""}

Would this change your recommendation?
 
In the Java everything is Object, thus you can not "macro" complicated structures.
The
HOSTS variable1, var2...
does not work in Java, if the "HOSTS" is not an object or a primitive type.
I do not know other solution than a "wrapper" class.

Bye, Otto.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top