Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Trying to get rid of redundancy?

 
Ashley Kin
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I'm trying to get rid of redundance in this program by factoring? Thank you for any help! (Sorry, I'm not sure how to use clipboard)


 
Winston Gutkowski
Bartender
Pie
Posts: 10427
63
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ashley Kin wrote:Hi, I'm trying to get rid of redundance in this program by factoring?

Well, the usual way is to put repeated code into a method and call it instead. And it seems like you have 2 big blocks of repeated code. You might want to think about parameter(s) for that method as well, so that it's self-contained.

Winston
 
Ralph Cook
Ranch Hand
Posts: 479
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
another way is not to post the same question in two forums. You've got this same one in "Java in General".

rc
 
Harsha Smith
Ranch Hand
Posts: 287
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Ralph Cook wrote:another way is not to post the same question in two forums. You've got this same one in "Java in General".

rc


good sense of humor!
 
Sven Eriksson
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ashley

Easiest would be something like this:



Hopefully that might help some, but you could also write it in another method and call to it
Remember, everyone codes differently...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic