
Hey everyone, I hope we are all doing well. Yesterday we learned what a method was. The best part was that it wasn’t painful at all since we have been using them for a week already. We have just now put a name to them. After that we took a look at how to use return in a method to return something from the object. We will continue on with that here with another example of how to implement a return.
No one seemed to have any issues in the last post with screen shots and highlights instead of entire code. Continuing on in that style we will highlight what we add since we are still working in all the same code. Let’s get started.
The first new lines we are going to add will be another set of public ints which will tell Java that something will be a number. In this case, length and width will be numbers. Go ahead and add these lines.
public int length;
public int width;

Then we need to move down and and give the length and width a value:
length = 10;
width = 5;

Now we have given our public int length and width a value to reference. Now we need to make it do something. So let’s move down a little further and give the return something to to do so that it will return something using our new length and width values.
return length*width;

With those five lines of code we now have a return that will give us the length*width of the book. If you remember from past articles the * means multiply. When we run this application, our OUTPUT window will display:

As always, play around with different configurations, sizes, numbers, words. Make it your own.
Happy coding everyone.








hey i want to learn android..
where i can find 3rd week parts..
rply ne soon..
thnx..