I have a method wherein i have to return a 2D String array.
The part of code for that method is as follow:-
public String[][] retrieveData(){
try{
int noOfRows = 0;
pstmt = con.prepareStatement("select * from category");
ResultSet rs = pstmt.executeQuery();
while(rs.next())
noOfRows++;
rs.first();
categoryContent = new String[noOfRows][noOfCols];
for(int i = 0 ; i < noOfRows ; i++){
for(int j = 0 ; j < noOfCols ; j++){
if(j == 0){
Integer categoryNo = new Integer(rs.getInt(1));
categoryContent[i][j] = categoryNo.toString();
}
else{
categoryContent[i][j] = rs.getString(j+1);
}
}
rs.next();
}
return categoryContent ;
}
catch(Exception e){
e.printStackTrace();
}
}
The error which i am getting at compile time is as follows:-
I:\DynamicWebpageCreator\WEB-INF\classes>javac *.java Category.java:134: missing return statement public String[][] retrieveData(){ ^** 1 error
Please help me soon. I am stuck with it. All the answers are highly appreciated!