reset password
Author Message
RandomAccess
Posts: 101
Posted 22:18 Feb 05, 2018 |

In the sorting class you ask us to make a static method with a generic type. But when I try that it has an error that says static methods can't return generic types. Am I misinterpreting something?

Arnav98
Posts: 48
Posted 22:31 Feb 05, 2018 |

The homework just requires you to make the sorting class in a way that it couldnt be instantiated. You can achieve it by making the class abstract and the sort method inside it concrete and static.

Last edited by Arnav98 at 22:33 Feb 05, 2018.
kknaur
Posts: 540
Posted 06:36 Feb 06, 2018 |
RandomAccess wrote:

In the sorting class you ask us to make a static method with a generic type. But when I try that it has an error that says static methods can't return generic types. Am I misinterpreting something?

The directions do not say to have this method return something.  Since the job of this method is to only sort the data given to it, there is no need to return anything.

 

Arnav98 wrote:

The homework just requires you to make the sorting class in a way that it couldnt be instantiated. You can achieve it by making the class abstract and the sort method inside it concrete and static.

The class should not be abstract.  This would not be the correct way to prevent instantiation.  Abstract classes are conventionally used as a base class for inheritance.  Since nothing will inherit from the Sorting class it would not make sense to make it abstract.

RandomAccess
Posts: 101
Posted 11:03 Feb 06, 2018 |

Should the sort method take parameters?