File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes What is the difference between int maxrows=20 and using Integer maxRows=new Integer(20);? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "What is the difference between int maxrows=20 and using Integer maxRows=new Integer(20);?" Watch "What is the difference between int maxrows=20 and using Integer maxRows=new Integer(20);?" New topic
Author

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

Sowm Herur
Ranch Hand

Joined: Jul 07, 2008
Posts: 32
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

Joined: Sep 29, 2008
Posts: 12617

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

Joined: Oct 13, 2005
Posts: 36478
    
  16
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: What is the difference between int maxrows=20 and using Integer maxRows=new Integer(20);?
 
Similar Threads
clarify my doubt
Integer...
Primitive types
premitive types & Wrapper clases
What is the difference between int maxrows=20 and using Integer maxRows=new Integer(20);?