Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Are Java Primitive Variables Objects?

333 views

Published on

A presentation which finds out the difference between Java primitive variables and Java objects.

~ Wasif Altaf

  • Be the first to comment

Are Java Primitive Variables Objects?

  1. 1. Yes Or NO!
  2. 2. Java Language Specifications
  3. 3. :: DEFINITIONS :: 4.12 Variables: A variable is a storage location and has an associated type, sometimes called its compile-time type, that is either a primitive type (§4.2) or a reference type (§4.3).
  4. 4. :: DEFINITIONS :: 4.12.1 Variables of Primitive Type: A variable of a primitive type always holds a value of that exact primitive type.
  5. 5. :: DEFINITIONS :: 4.12.2 Variables of Reference Type: A variable of a class type T can hold a null reference or a reference to an instance of class T or of any class that is a subclass of T.
  6. 6. Are Variables Objects? NO!
  7. 7. Byte Float Integer Type Wrapper Classes Long Character Double
  8. 8. Boxing valueOf( type arg ) AutoBoxing intValue( ) charValue( ) booleanValue( ) Unboxing
  9. 9. :: EXAMPLE :: Integer x , y ; x = 12 ; y = 15 ; System.out.println( x + y );
  10. 10. Are Variables Objects? NO! NO! NO!
  11. 11. :: REFERENCES :: http://java.sun.com/docs/books/jls/download/langspec-3.0.pdf http://www.javaranch.com/campfire/StoryCups.jsp http://www.javaranch.com/campfire/StoryPassBy.jsp http://java.sun.com/docs/books/tutorial/java/data/numberclasses.html http://java.sun.com/j2se/1.5.0/docs/guide/language/autoboxing.html http://forums.sun.com/thread.jspa?threadID=5387311
  12. 12. Discussion
  13. 13. Thanks

×