Reputation: 1
I am trying to upload 2 images and this is a class used for that. However, I am getting unreachable statement error.
public class uploadinfo {
private String imageName;
private String imageURL;
private String imageURL2;
public uploadinfo(){}
uploadinfo(String name, String url) {
this.imageName = name;
this.imageURL = url;
this.imageURL2 = url;
}
public String getImageName() {
return imageName;
}
public String getImageURL() {
return imageURL;
return imageURL2;
}}
Upvotes: 0
Views: 40
Reputation: 502
If you want to return both the imageURLs from the same method then you should use a Pair object. like this -
public Pair<String, String> getImageURL(){
return new Pair(imageURL, imageURL2);
}
Upvotes: 0
Reputation: 129
public String getImageURL() {
return imageURL;
return imageURL2;
}
Exeuction of a non-void method ends when a first RETURN statement is encountered, which is return imageURL;
in your example. The second return is never executed ( = it is unreachable), because first one returns execution back.
You might split the method into two methods, for example getImageURL()
and getImage2URL()
, or return the URLs somehow packed (split by a space or any other character of your choice).
Upvotes: 0