• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Tim Cooke
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
Saloon Keepers:
  • Piet Souris
Bartenders:

About Arrays.toString(String[]) method

 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
best scout
Posts: 1294
Scala IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Sheriff
Posts: 22907
132
Eclipse IDE Spring TypeScript Quarkus Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Shashi Kala
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 1294
Scala IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you,

I did the second thing..
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic