Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update AreaRec.java #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mathewjosephta
Copy link

1. Removed undeclared area variable in the getArea() method:
Instead of using a separate variable, you can directly return the result of length * breadth.

2. Changed setdimension to setDimension:
Following Java naming conventions (camelCase) for method names, the method was renamed to setDimension.

3.Consistent data types:
In the original code, you used float for length and breadth, so I ensured that getArea() returns float as well, for consistency.

4. Added sc.close():
It's a good practice to close the Scanner object after use to avoid resource leaks.

1. Removed undeclared 'area' variable in the 'getArea()' method:
                Instead of using a separate variable, you can directly return the result of length * breadth.

2. Changed setdimension to setDimension:
                Following Java naming conventions (camelCase) for method names, the method was renamed to setDimension.

3.Consistent data types:
              In the original code, you used float for length and breadth, so I ensured that getArea() returns float as well, for consistency.

4. Added sc.close():
              It's a good practice to close the Scanner object after use to avoid resource leaks.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant