aspose file tools
The moose likes Beginning Java and the fly likes error in system.out.println Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "error in system.out.println" Watch "error in system.out.println" New topic

error in system.out.println

cchetan jain
Ranch Hand

Joined: Jul 05, 2009
Posts: 30

why this gives an error..while when we use object in the argument for print never gives an error??
please sort out this..
i m very curious about it?
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 40988
What error did you get? What do you think it means?
Rob Spoor

Joined: Oct 27, 2005
Posts: 19899

The problem is that, as the compiler error tells you, there are (at least) two print methods that can accept null. Actually there are three; also print(Object).

Now the compiler tries to find the most specific version of an overloaded method. Both char[] and String are sub types of Object, so that's why the third method is not considered. char[] and String are both too distinct for the compiler to choose for you. To fix this, specify the type by casting:

How To Ask Questions How To Answer Questions
rocket mass heater kickstarter
subject: error in system.out.println