New course! Every coder should learn Generative AI!
Try a free lesson+ 9
you can use a set https://docs.oracle.com/javase/7/docs/api/java/util/Set.html which does not allow for duplicates.
or https://stackoverflow.com/questions/17967114/how-to-efficiently-remove-duplicates-from-an-array-without-using-set
Second answer. Instead of printing, add "current" to a new array