Is this example a bad coding style? Is it better to use other variable names in the constructor?

Class Myclass{ String name; String lastName; Myclass(String name, String lastName){ this.name = name; this.lastName = lastName; } } 
  • class is written with a small letter. In this example, you can change the class name Myclass , the access modifier for the constructor and the fields. Adding final possible, but it already depends on context - Artem Konovalov
  • @Andrei_Ert If the question concerns only the initialization of fields in the constructor, then using the same name and this is an absolutely normal practice, the majority adheres to it. - fromSPb

0