File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes null variable casting Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "null variable casting " Watch "null variable casting " New topic

null variable casting

deenbandhu prasad

Joined: Feb 21, 2008
Posts: 9
public class Test1{
static void method(Object obj){
static void method(String str){
public static void main(String args[]){

The output of above program is "String". Can some one explain how is java is handling "null" variable and casting is to String and not object.
Christophe Verré

Joined: Nov 24, 2005
Posts: 14688

I think this FAQ will help you.

[My Blog]
All roads lead to JavaRanch
deenbandhu prasad

Joined: Feb 21, 2008
Posts: 9
Thanks a ton.. it did helped.
I agree. Here's the link:
subject: null variable casting
It's not a secret anymore!