Hi, I have an assignment requiring me to use the printStringArray method, but I can't find any examples on how to do so in my textbook or on the web. Can anyone provide an example please? I'd be very greatful!

Recommended Answers

All 3 Replies

Do you have to write this method yourself? If not, I'm 99% sure its not part of the standard API. If you just have to use the method some common sense is helpful. Method's are named so that you don't really need to know how they work to use them. printStringArray most likely takes a String[] parameter, and prints it out.

Ok so if I had an array called "reader", would I use the method as such: printStringArray(reader[]) ? Or would it be reader.printStringArray(reader[]) ?

If you are using the printStringArray() in the class it is declared in then it would be printStringArray(reader); . Otherwise you would have to know what class it is declared in, and then create an object of that type and use it that way.

public static void main(String[] args){
     ArrayPrinter printer = new ArrayPrinter(); //printStringArray method declared in this class
     String[] reader = new String[5];
     printer.printStringArray(reader);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.