Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java naming convention for static mutator methods

For static methods in Java, the parameter cannot have the same name as a global static variable. Is there a convention for naming the parameter? ...just a curiosity.



private static volatile int metBetYetPetLetJet = 8675309;

public static void setMetBetYetPetLetJet (int metBetYetPetLetJet0) { metBetYetPetLetJet = metBetYetPetLetJet0; }

like image 724
farm ostrich Avatar asked Oct 24 '25 14:10

farm ostrich


1 Answers

The parameter absolutely can have the same name:

public class Foo {

    private static volatile int metBetYetPetLetJet = 8675309

    public static void setMetBetYetPetLetJet (int metBetYetPetLetJet) {
        Foo.metBetYetPetLetJet = metBetYetPetLetJet;
    }
}

Alternatively, I often just use value as the parameter name for a setter. That may be the influence of C# though :) Another option is newValue.

like image 82
Jon Skeet Avatar answered Oct 27 '25 03:10

Jon Skeet