aspose 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
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: 40071
    
  28
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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: What is the difference between int maxrows=20 and using Integer maxRows=new Integer(20);?