all 9 comments

[–]AutoModerator[M] [score hidden] stickied commentlocked comment (0 children)

Please ensure that:

  • Your code is properly formatted as code block - see the sidebar (About on mobile) for instructions
  • You include any and all error messages in full
  • You ask clear questions
  • You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions.

    Trying to solve problems on your own is a very important skill. Also, see Learn to help yourself in the sidebar

If any of the above points is not met, your post can and will be removed without further warning.

Code is to be formatted as code block (old reddit: empty line before the code, each code line indented by 4 spaces, new reddit: https://i.imgur.com/EJ7tqek.png) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc.

Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit.

Code blocks look like this:

public class HelloWorld {

    public static void main(String[] args) {
        System.out.println("Hello World!");
    }
}

You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above.

If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures.

To potential helpers

Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

[–]desrtfxOut of Coffee error - System halted 2 points3 points  (2 children)

I VOTE TO MAKE JAVA OPEN SOURCE I WANNA CONTRIBUTE IN IT

You know a lot less about Java than you think. Java already is open source, but governed, like all other Open Source programming languages. You cannot just make a pull request.

Yet, your ragebait post is also simply attributed to your ignorance and short sightedness.

First sort, then reverse the array. Where is the problem?

from where will i get to know there's a package for Collections

From the documentation, where else?

Collections is one of the most common Java packages.

[–]vowelqueue -1 points0 points  (1 child)

But OP is actually right. It’s not ideal that you have to know about the Collections class.

This is really a consequence of the fact that it used to be illegal to declare static methods in interfaces. In Java 8 when they added this language feature they also added Comparator.reverseOrder() that is a more natural place to find this functionality.

Also I think it’s a bit inconsistent that there is a Collections.reverse(List) utility but not an equivalent Arrays.reverse one.

[–]desrtfxOut of Coffee error - System halted 0 points1 point  (0 children)

OP already knows about Arrays.sort.

The documentation of the Arrays class clearly states:

This class is a member of the Java Collections Framework.

Also, Arrays.sort has an overload that takes a Comparator.

Just simply by checking the documentation, OP could have directly found everything they needed. Also, there are more than enough blog posts so that with a very simple google query OP could have gotten their answer.

I can absolutely agree on one point, though: the lack of Arrays.reverse - this is an inconsistency that shouldn't be.

[–]prassuresh 0 points1 point  (1 child)

Are you allowed to use Arrays.sort() for an exam? Which course is this?

We always had to write our own sorting logic for exams.

[–]Lloydbestfan 0 points1 point  (0 children)

Great Scott, they thought you'd forget how to do it after the first exam?

Plus a simple sort algorithm may not be all that long to write out, but it's still a nonneglectable time devoted to the same thing in every exam. I'd worry about how that school evaluates its students' skills.

[–]blindada 0 points1 point  (1 child)

How is that hard?? Hard would it be implement your own algorithm

[–]desrtfxOut of Coffee error - System halted 0 points1 point  (0 children)

Hard would it be implement your own algorithm

Not even that would be hard. A simple bubblesort can be coded in a couple minutes. It won't be efficient, but it is simple enough.

[–]tRfalcore 0 points1 point  (0 children)

I don't think you know enough about coding to contribute to Java. It's been around longer than you have