开发者

Defining as constants in Java

开发者 https://www.devze.com 2023-01-20 03:34 出处:网络
lis开发者_StackOverflow社区t.loadRequestParms(request, \'a\', 20); This method takes three parameters
lis开发者_StackOverflow社区t.loadRequestParms(request, 'a', 20);

This method takes three parameters

  1. a request object.
  2. a char
  3. an integer

Now how to define these as constants somewhere and use it in this method.


I think I understand what you mean, but more detail would have been useful.

static final Request MY_REQUEST_CONST = someRequest;
static final char MY_A_CONST = 'a';
static final int MY_INT_CONST = 20;

list.loadRequestParms(MY_REQUEST_CONST, MY_A_CONST, MY_INT_CONST);

Some things to note. A constant in Java is created by the final static keywords. Convention suggests that constant variable names are uppercase.


How to define constants in Java - tutorial.

Passing parameters in Java - an article.


Constants? You mean variables that don't change and are final? Same copy of which lasts all throughout, i.e. are static? And they can also be publicly accessible.

http://www.devx.com/tips/Tip/12829

public class MaxUnits {
   public static final int MAX_UNITS = 25;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消