how to remove duplicate words from an array in java

I am reading a file then calling a string[] method that breaks the line up into individual words, adds each word to an array of unique words (no duplicate words), and returns the array of unique words. I cannot figure out how to only print each word once but here is what I have so far. static public String[ ] sortUnique( String [ ] unique, int count) { String temp; for(int i = 1; i < count; i++) { temp = unique[i].replaceAll("([a-z]+)[,.?]*", "$1");; int j; for(j = i - 1; j>= 0 && (temp.compareToIgnoreCase(unique[j]) < 0);j--) { unique[j+1] = unique[j]; } unique[j+1] = temp; } return unique; } And here is the data file. Is this a dagger which I see before me, The handle toward my hand? Come, let me clutch thee. I have thee not, and yet I see thee still. Art thou not, fatal vision, sensible To feeling as to sight? Or art thou but A dagger of the mind, a false creation, Any help would be greatly appreciated!
Read stackoverflow.com/questions/357421/…

以上就是how to remove duplicate words from an array in java的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏