aspose file tools*
The moose likes Java in General and the fly likes Primitive types Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Primitive types" Watch "Primitive types" New topic
Author

Primitive types

raj joe
Ranch Hand

Joined: Mar 17, 2005
Posts: 99
What is the difference between the following statements.How memory is allocated.

int i=1;
Integer i=new Integer(1)
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24166
    
  30

The int is either held in a local variable -- i.e., a slot in the stack frame of the method -- or as part of a heap object, if it's a member. The Integer is an object, allocated on the Java heap. The reference to the Integer (the second variable "i") is held in one of the same two places, depending.


[Jess in Action][AskingGoodQuestions]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Primitive types
 
Similar Threads
Casting an array
Question of Arrays.asList()
parameter passing question for array reference
converting string to integer
Integer Constant Pool ????