on 07-07-2009 9:52 AM
Hi!
I am currently developing my first PI Adapter Module. In SAP sample coding GetHostName I find the following declarations and I ask me what's the meaning and/or purpose of these declarations:
public static final String VERSION_ID = "$Id://tc/aii/30_REL/src/_adapters/_sample/java/user/module/GetHostName.java#1 $";
satic final long serialVersionUID = 7435850550539048631L;
And additionally how I have to declare these two variables for my adapter module ... This comes true especially for VERSION_ID, because serialVersionUID can be generated by NWDS using quick fix feature. It then declares such a variable ...
Thanxs for any hint in advance!
Regards,
Volker
Hi Pavel,
public - this is the visibility modifier (it means that the body method can be call by any outside method)
static - the method is a static instance of the class. Not sure what exactly it does though.
final
indicates that the value of the variable won't change - in other words, a variable who's value can't be modified after it is declared.
Use public final static String
when you want to create a String
that belongs to the class (no instance necessary to use it), and that won't change, for instance when you want to define a String
constant that will be available to all instances of the class, and to other objects using the class, depending on the access modifier:
public final static String MY_CONSTANT = "SomeValue"; // ... in some other code, possibly in another object, use the constant: if (input.equals(MyClass.MY_CONSTANT)
All the variables are implicitly public static final
in a Java Interface.
Is it a good coding practice to use public static final in constant variable although it is declared inside an Interface.
For example :
public interface TestInterface{ public static final String EX_CONSTANT = "ABC"; public static final int EX_INT_CONSTANT = 5; public static final double EX_DOUBLE = "5.0"; public static final Integer EX_INTEGER = 10; }
Refer below links
Hope it will helpful..
Regards
Bhargava krishna
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Volker,
please how do you resolved it?
I have the same problem.
Thx.
Pavel.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
88 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.