Java Question Setter- and Getter-Methoden in Java and B4A

Amalkotey

Active Member
Licensed User
Longtime User
Hello,

in my Java classes B4A I implemented setter and getter methods, as B4A can not call parameterized constructor. Now I noticed that in this B4A not visible. Instead of me in the auto-complete the setter and getter view, appear only the class variables. Accordingly, I have the setter argument by assigning equal sign.

B4X:
DIM LizMa As LizMaLib
LizMa.Password = Passwort

instead of

B4X:
DIM LizMa As LizMaLib
LizMa.setPassword( String-argument )

Is this normal? The functionality is given and the parameter passing is correct. Thanks for the info in advance.

regards
Amalkotey
 

agraham

Expert
Licensed User
Longtime User
Basic4android synthesises properties by assuming that

public int getXXX() { ... } // note no parameters
and
public void setXXX(type value) { ... } // note only one parameter and void return

represent a property.

If you want to see the setter and getter use

public int GetXXX() { ... } // note upper -case
and
public void SetXXX(type value) { ... } // note upper -case
 

Amalkotey

Active Member
Licensed User
Longtime User
Setter- and Getter-Methods - Conventions SUN / Oracle

Hello Andrew,

thanks for the info. This corresponds procedure but not the Java naming conventions. According to Sun / Oracle have provided the following conventions:

  • It is used basically speaking identifier, ie, those that have already clearly close to their meaning. This also applies if the identifier advised by a very long time. A prime example of the standard library is the class name ArrayIndexOutOfBoundsException. An exception to this rule identifier such as i and j, which are "known for their use in loops."
    [*]he names of simple data types are completely written small (int, char, boolean, ...).
    [*]Constants, ie data elements with the final modifier, are completely written large (Label.CENTER).
    [*]Identifiers of classes always have a capital letter and lower case otherwise. If the identifier is composed of several words, the respective initial letters are capitalized (LayoutManager).
    [*]Identifiers of variables, methods and data elements always begin with a lowercase letter. Sets the identifier is composed of several words, the initial letters of other words are capitalized (Button.getPreferredSize()).
Difficult to get used to transform now that I at 07. January 2011, the store for SCJP 6.0 certification.

regards
Amalkotey
 
Last edited:

agraham

Expert
Licensed User
Longtime User
I suspect you have translated that set of Sun/Oracle conventions from another language as the English doesn't make much sense.

However as the Basic4android Java code is not intended for use or interpretation by other human beings adherence to convention is a bit irrelevant.
 
Top