Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What is the difference between int maxrows=20 and using Integer maxRows=new Integer(20);?

 
Sowm Herur
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the difference between int maxrows=20 and using Integer maxRows=new Integer(20);?

Can we use int maxrows=20 to store maxrows instead of using Integer maxRows=new Integer(20);?

In what scenarios do we decide on what to use when?

Please Clarify
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One's an object, one's a primitive. Yes, you can. If you're using Java 1.5+ it's relatively unusual you need to care because of autoboxing.
 
Campbell Ritchie
Sheriff
Posts: 48441
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please search for primitives; there have been two threads about primitives in the last week or so. You will get faster performance with int than Integer.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic