Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Pass 2D array between methods

 
Ralph King
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
all,

I am struggling to pass my 2D array between classes. The following getMethod should return a valid 2D array:

public String[][] getResults(){
return (resultSet);
}


However when i try to access from another class my first attempts fall woefully short:

String test[][]=newData.getResults();

When I try to access elements they are all null. how do i accomplish this?

All help very welcome.
 
Rob Spoor
Sheriff
Pie
Posts: 20605
60
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch!

Where and how have you initialized resultSet?
 
Campbell Ritchie
Sheriff
Pie
Posts: 49733
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome again

I am afraid I am going pedantic: there is no such thing in Java™ as a 2D array. There are arrays of arrays, however.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic