• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how sort math.sqrt

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 491
23
Eclipse IDE Firefox Browser Spring VI Editor AngularJS Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 491
23
Eclipse IDE Firefox Browser Spring VI Editor AngularJS Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 79178
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
     
    Don't get me started about those stupid light bulbs.
    reply
      Bookmark Topic Watch Topic
    • New Topic