aspose file tools
The moose likes Java in General 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
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply locked 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
Leandro Coutinho
Ranch Hand

Joined: Mar 04, 2009
Posts: 415
int x = 10; // x is primitive
Integer y = new Integer(10); // y is a reference to an object

Primitives can't invoke methods of its wrapper classes.
Primitives can't be null, while objects can.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 32654
    
    4
Closing as duplicate.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: What is the difference between int maxrows=20 and using Integer maxRows=new Integer(20);?
 
Similar Threads
What is the difference between int maxrows=20 and using Integer maxRows=new Integer(20);?
Integer...
clarify my doubt
Primitive types
premitive types & Wrapper clases