jQuery in Action, 2nd edition*
The moose likes Beginning Java and the fly likes Display method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Display method" Watch "Display method" New topic
Author

Display method

Rupinder Bains
Ranch Hand

Joined: Jul 23, 2002
Posts: 65
How would you code a displayPoint method for a Point class with the attributes int x and int y set to null???
Jon Strayer
Ranch Hand

Joined: Dec 04, 2002
Posts: 133
I think I'd just let it throw a NullPointerException.


Jon
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Primitive types, like int, *can't* be set to null...


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
To expand on Ilja's answer, null is used to show that a pointer is not pointing to anything. Since primitives are not pointers they can never be set to null.


Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Display method
 
Similar Threads
DaysOld simplify?
java.lang.exception
Scrolling a JScrollpane through Code.
Number Wrapper classes - autoboxing
Clarification for such a method