It's not a secret anymore!*
The moose likes Beginning Java and the fly likes how to sovle these two errors~~~help~~~ 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 "how to sovle these two errors~~~help~~~" Watch "how to sovle these two errors~~~help~~~" New topic
Author

how to sovle these two errors~~~help~~~

Alex cordes
Greenhorn

Joined: Nov 15, 2005
Posts: 15
when i run my program,errors appear:

"WriteString(java.lang.String) in FileOutput cannot be applied to (java.lang.Object)

this is anothor program's error:

"incompatible types - found java.lang.Object but expected java.lang.String"

i cant get it! anyone help me solve both of them???
thanks a lot~~~
Rick Beaver
Ranch Hand

Joined: Dec 14, 2004
Posts: 464
Both the same problem - cast your Object to a String by placing the cast (String) in front of it



should be



I am assuming that the reference you are giving to the WriteString is, in fact, a Strnig object of course - if it is a different type then this will not work.


ph34r my 133t j4v4 h4><0r1ng sk177z
Rick Beaver
Ranch Hand

Joined: Dec 14, 2004
Posts: 464
One other point - just a matter of convention - methods in Java are usually written with the first character lowercase and the remaining words denoted by an uppercase character.

If WriteString is a method - it should really be writeString
[ November 16, 2005: Message edited by: Rick Beaver ]
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9044
    
  10
Duplicate of this post


JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Alex cordes
Greenhorn

Joined: Nov 15, 2005
Posts: 15
Originally posted by Rick Beaver:
Both the same problem - cast your Object to a String by placing the cast (String) in front of it



should be



I am assuming that the reference you are giving to the WriteString is, in fact, a Strnig object of course - if it is a different type then this will not work.


thanks for ur reply~~~yes~~~i make the 1st one correct, but cant do it with the 2nd one:
the wrong code is:
"String name = names.get(i);"
how to change the type of it?
Rick Beaver
Ranch Hand

Joined: Dec 14, 2004
Posts: 464
Alex cordes
Greenhorn

Joined: Nov 15, 2005
Posts: 15
Originally posted by Rick Beaver:


oh~~~man~~~how fast can u be??? u r amazing!!!~~~thanks a lot~~~ )))
Rick Beaver
Ranch Hand

Joined: Dec 14, 2004
Posts: 464
No problem
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to sovle these two errors~~~help~~~
 
Similar Threads
anyone help me!!!~~~
Client to invoke a deployed EJB
EJB Server Exception
Using Axis2 the WSDL2Java is giving Java:16: "Object cannot be applied to" errors.
Cannot start Naming Server in WTE ?