• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

distinct

 
Tom Cummings
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My teacher has this method to make a boolean array and get distinct values from an array. I have tried to run it but it only prints the array not the unique values from it.
 
Ivan Franko
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, could you please provide Actual and Expected results?
 
Campbell Ritchie
Sheriff
Pie
Posts: 49367
62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is that method supposed to do?
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15354
39
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You say the method "only prints the array", but the code you posted does not print anything at all.

Note that lines 5 and 6 are unnecessary - when you create a new array of booleans (line 4), they're already all initialized to false. You don't have to do that explicitly.
 
Tom Cummings
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is suppose to take an array (int [] list = {50, 40, 70, 85, 40, 20, 40, 55, 95,57};) Then print the method
from another class with non duplicates.


The above is the other class
 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jesper de Jong wrote:You say the method "only prints the array", but the code you posted does not print anything at all.


This problem still stands. It seems like you want the method to print something. If you do you should add some code which does some printing.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic