It's not a secret anymore!*
The moose likes Beginning Java and the fly likes About Arrays.toString(String[]) method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "About Arrays.toString(String[]) method" Watch "About Arrays.toString(String[]) method" New topic
Author

About Arrays.toString(String[]) method

Shashi Kala
Ranch Hand

Joined: Jan 27, 2008
Posts: 46
Hi all,

I am using Arrays.toString(String[]) method to display the information in logs. But I am getting an error like 'the method toString() in the type object is not applicable for the arguments(String[])' in eclipse, when I use this method. What is the wrong with this?

Regards,

Shashi Kala
Marco Ehrentreich
best scout
Bartender

Joined: Mar 07, 2007
Posts: 1282

Hi Shashi,

it's difficult to tell you the exact problem without knowing the bit of code which makes you trouble. Anyway the Arrays.toString() methods need one parameter which has to be an array of some type. Are your "log entries" arrays of string or what? Take a look at the )]API doc then you can surely figure it out yourself

Marco
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19725
    
  20

The toString methods have only been added in Java 5.0. If you are using Java 1.4 or below, there is only one toString() method and that's the one inherited from Object. And that isn't static of course.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Shashi Kala
Ranch Hand

Joined: Jan 27, 2008
Posts: 46
Hi Marco,

See the code here I am using.

Where obj.getIDs() returns string array. printLog() method takes the arguments string,string. meth variable also a string.


Here in first line eclipse is showing me an error.
Shashi Kala
Ranch Hand

Joined: Jan 27, 2008
Posts: 46
and one more thing..

I am using java 1.4 version. But Arrays.toString() is since 1.5 version right? then is there any way to get the same work done?
Marco Ehrentreich
best scout
Bartender

Joined: Mar 07, 2007
Posts: 1282

Hi Shashi,

I think you can do two things to get this done:

1) Use Java >= 1.5 if possible.

2) Write your own helper class/method which takes your array of Strings and returns a concatenated String containing all the Strings of the array. I think this wouldn't be to difficult.

Marco
Shashi Kala
Ranch Hand

Joined: Jan 27, 2008
Posts: 46
Thank you,

I did the second thing..
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: About Arrays.toString(String[]) method