1,105,363 Community Members

Macro in Java

Member Avatar
wolfcode
Newbie Poster
1 post since Mar 2008
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Hi, I have to write a simple Java code real quick and was wondering how to write the following macro in Java:

#define BUF 256
Member Avatar
Ezzaral
Posting Sage
7,431 posts since May 2007
Reputation Points: 2,714 [?]
Q&As Helped to Solve: 953 [?]
Skill Endorsements: 31 [?]
Moderator
Featured
 
0
 

There are no macros in Java. You would define a class or interface constant for that purpose.

Question Answered as of 5 Years Ago by Ezzaral
Member Avatar
rernst
Newbie Poster
1 post since May 2009
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

You probably would do something like:

public final static int buf = 256;

It's not exactly the same thing but performing about as good as it gets. It's comparable to a const.

Member Avatar
alwinnjavaroor
Newbie Poster
2 posts since Oct 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

hi 'rernst' recently a friend of mine asked me to convert a c++ coded pgm to java codes
and there was macro [ #define f(x) x*x*x ] how do get java equivalent code for this?
using a function call is undesirable for this pgm ....can u help on this

You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article