About 69,700 results
Open links in new tab
  1. java - How do getters and setters work? - Stack Overflow

    Jan 10, 2010 · 40 In Java getters and setters are completely ordinary functions. The only thing that makes them getters or setters is convention. A getter for foo is called getFoo and the setter is called …

  2. Java Getter and Setters for simple properties best practice

    Mar 9, 2024 · The get and set are implicitly used when referencing the property. So in practice 99% of the time I use a public property with getter and setter because it gives me the added benefit of …

  3. Post Java-14 (records) getter/setter naming convention

    Jan 30, 2020 · Java 14 introduced records feature. Record creates getter with the same name as field, so one would write print (person.name ()) for example. But old Java bean convention dictates that …

  4. java - How can I get @getter and @setter? - Stack Overflow

    I often see the following annotations in code: @Getter @Setter public int test = 1; I know I can create getter and setter methods using this annotations. But which classes/library do I need to use...

  5. java - Why use getters and setters/accessors? - Stack Overflow

    Allowing inheritors to change the semantics of how the property behaves and is exposed by overriding the getter/setter methods. Allowing the getter/setter to be passed around as lambda expressions …

  6. class - Java :Setter Getter and constructor - Stack Overflow

    Jul 30, 2013 · I'm a bit confused about the use of getter/setters and constructors (see the below code for an example) public class ExampleClass { private int value = 0; public ExampleCla...

  7. Lombok Annotations Not Working in Spring Boot Project (Java 21)

    Dec 6, 2024 · I am working on a Spring Boot project using Lombok to generate boilerplate code such as getters, setters, and constructors. Despite having the correct Lombok dependency in the pom.xml, …

  8. getter setter - When to use get/set Methods in java - Stack Overflow

    Jul 29, 2014 · In Java, using a getter and setter is usually considered best practice. This is because if you ever need to change your code to do something else when a property is accessed or modified, …

  9. java - Lombok is not generating getter and setter - Stack Overflow

    Quickly, I noticed that Lombok is not generating getters and setters for my classes, although the @Getter and @Setter are being correctly recognised by Eclipse. Both computers use the same …

  10. For a boolean field, what is the naming convention for its getter/setter?

    For a field named isCurrent, the correct getter / setter naming is setCurrent() / isCurrent() (at least that's what Eclipse thinks), which is highly confusing and can be traced back to the main problem: Your …