+ 1

Are getters and setters inbuilt functions in java or are they user defined??

24th Jul 2020, 11:46 AM
Ayushi Saxena
Ayushi Saxena - avatar
2 Antworten
+ 3
For your own classes you'll have to implement them. Many IDEs provide the functionality to generate them automatically.
24th Jul 2020, 12:00 PM
Sandra Meyer
Sandra Meyer - avatar
+ 1
user-defined. However in API, you can see methods like String.getBytes() . And in Java 14 there is new datatype: record with build-in getters/setters, but it is just 'preview feature' for future java. https://www.baeldung.com/java-record-keyword
25th Jul 2020, 10:15 AM
zemiak