answersLogoWhite

0

What is getters in java?

Updated: 8/19/2019
User Avatar

Wiki User

13y ago

Best Answer

GETters and SETters are functions that GET and SET the value of a private variable.

example:

.........

private int power;// -----------------------

......................................................... // |

.......................................................... // |

........................................................... // |

........................................................... // | The User Gets The value of power

.......................................................... // |

public int getPower(){ //...................... |

return power;// <---------------------------

}

:)

User Avatar

Wiki User

13y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is getters in java?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What are Java beans?

In eclipse you can create java bean by generating getters and setters. Getters and setters are generated as ' alt + shift + s + r'.


What are setters and getters?

As the name suggest Setters are to set value of an attribute and Getters are to get value of an attribute. sometime they are also called java beans.


What is the difference between Java bean and bean?

JAVA beans and coffee beans are two very different things . JAVA beans are used to generate getters and setters. while coffee beans are use to make coffee.


What is use of getters and settersin java?

A setter is used to change a field; a getter to get its value. The fields themselves are usually declared as private, for reasons that can be summarized with the term "encapsulation".


How do you create a bean in Java?

In eclipse java beans can be created by using getters and setters. Example: public class Login { public String lmail; public String getLmail() { return lmail; } public void setLmail(String lmail) { this.lmail = lmail; }


What are some attention getters for cell phones?

attention getters for cell phones


What method in java performs some action (i.e. not assignments) other than returning a value?

Methods that are neither mutators (setters) or accessors (getters). This primarily includes the class constructors (the initialisers) and the class destructor (the restorer).


What do the 4th 5th and 6th place-getters receive in the Olympics?

I think just ribbons. The 1st 2nd and 3rd place-getters get Medals.


What are some attention getters of baklava?

Pistachio baklava from mansoura.com....tasty!


What actors and actresses appeared in Goat Getters - 1924?

The cast of Goat Getters - 1924 includes: Tommy Hicks as Tommy - the Fat Kid Jack Lloyd Jack McHugh as Jack Doreen Turner


What do you call people who make things happen?

Go-getters, sparkplugs,


What does get mean in java and what is the function of it?

Instead of using public variables, people have a tendency to use it as private variable (They call it encapsulate) and only allow other access these variable via getters and setters. For example: class Calculator { private int a; public int getA(){ return a; } public void setA(int a){ this.a = a; } }