File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "error in system.out.println" Watch "error in system.out.println" New topic
Author

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 ..it never gives an error??
please sort out this..
i m very curious about it?
Campbell Ritchie
Sheriff

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

Joined: Oct 27, 2005
Posts: 19651
    
  18

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:


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
jQuery in Action, 2nd edition
 
subject: error in system.out.println
 
Similar Threads
Arrays doubt
K&B page no 121 doubt
for loop not compiling
definite assignment
Doubt in Exceptions.