how you returning values from methods in java its


How you Returning Values From Methods in java ?

It's frequent meaningful to have a method return a value to the class which is known as it. This is accomplished through the return keyword at the end of a method and through declaring the data type that is returned by the method at the starting of the method.
For example, the next getLicensePlate() method returns the current value of the licensePlate field in the Car class.

String getLicensePlate() {
return this.licensePlate;
}

A method such as this in which merely returns the value of an object's field or property is called as a getter or accessor method.
The signature String getLicensePlate() implies that getLicensePlate() returns a value of type String and takes no arguments. Inside the techniques the line

return this.licensePlate;

returns the String holds in the licensePlate field to whoever called as this method. It is significant in which the type of value returned through the return statement match the type declared in the methods signature. If it does not, the compiler will complain.

Request for Solution File

Ask an Expert for Answer!!
JAVA Programming: how you returning values from methods in java its
Reference No:- TGS0284544

Expected delivery within 24 Hours