• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

how sort math.sqrt  RSS feed

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I have code that count the square.
But I want to sort the width and height.

I have two questions:
When I use return I get the error: unnecessary return statement. How is this possible?

And how can I use the variable 'end' for to sort the width and height?

can someone help me?

thanks in advance

 
Ranch Hand
Posts: 461
22
Android Chrome Eclipse IDE Google App Engine Java Notepad Oracle Ubuntu Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have not seen any constructor for the Class object in the API then how can you do like this:

their is built in class for Class type object in the API in lang package if you have named any
class "Class" then rename it.

also the curly braces after the abstract method doesnot carry any identifier thats why are you
an error.
 
praveen kumaar
Ranch Hand
Posts: 461
22
Android Chrome Eclipse IDE Google App Engine Java Notepad Oracle Ubuntu Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
welcome to javaranch wesley.

what i think is you have an intension of providing a body to abstract method,but it is not the definition of abstract method.so
in order to do so simply replace abstract with any other type or Override it in the extending class.and also please mention me what do you need to sort or more specifically about your problem.
 
Marshal
Posts: 60168
188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome again

I am afraid I don't understand the design of the app. You have got an abstract class and made it implement Comparable. That doesn't look quite right. Read this, which tells you that Comparable represents a total ordering and a natural order. That means that for every pair of instances of that class, you can hold your hand on your heart and say one of the following things:-
  • 1: Object 1 is greater than object 2.
  • 2: Object 1 is less than object 2.
  • 3: Object 1 is the same as object 3.
  • I am not convinced you can do that with shapes. If you have a circle diameter 10, is it larger or smaller than a square with a diagonal 10? Does a circle have height and width? Does a circle have a diagonal?

    By the way, there is a method in the Math class which calculates diagonals for you without your having to do all the arithmetic yourself.
     
    It is sorta covered in the JavaRanch Style Guide.
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!