What does the return inside the if statements do in the following code?
public void startElement(String namespaceURI, String localName,String qName,
The return here is probably used in order to "improve" the performance of the method, so that other comparisons are not executed, once the needed scenario is performed.
However, it's not good practice to have multiple return points in a method.
As stated in my comments I'd try a different approach to achieve the flow of the code in question.
It finishes the method so the code below it, is not executed.
Does it takes us out of the if statement and proceeds to next statement or it takes us out of the method startElement?
It takes you out of the method.. The return statement terminates the execution of a function
it will return what you declared in the method head (here void = nothing = it will just end the method)
The return will end the flow of the method, and is functionally identical to using a shorter else if
chain like
/* if (localName.equals("channel")) {
currentstate = 0; // This can be removed because it's the default below.
} else */ if (localName.equals("image")) {
// record our feed data - you temporarily stored it in the item :)
_feed.setTitle(_item.getTitle());
_feed.setPubDate(_item.getPubDate());
} else if (localName.equals("item")) {
// create a new item
_item = new RSSItem();
} else if (localName.equals("title")) {
currentstate = RSS_TITLE;
} else if (localName.equals("description")) {
currentstate = RSS_DESCRIPTION;
} else if (localName.equals("link")) {
currentstate = RSS_LINK;
} else if (localName.equals("category")) {
currentstate = RSS_CATEGORY;
} else if (localName.equals("pubDate")) {
currentstate = RSS_PUBDATE;
} else {
currentstate = 0;
}
return always takes control out of calling method.