How to return null-optional and ""-optional

I was looking at the video and in there it was saying that if userinfo/query is not existent, we should return null.
And when I look at the documentation of the function, it says the results must not be null.

I was kind of confused what should we return when there is no userinfo/query.

Thanks in advance
Bahadır.

For user info it says:


	/**
	 * @return the result of parsing the non-terminal "query" in the grammar or
	 *         {@code null} if the URI did not contain a query part
	 */
	public String getQuery();

	/**
	 * @return the result of parsing the non-terminal "userinfo" in the grammar
	 *         or {@code null} if the URI did not contain user information
	 */
	public String getUserInfo();

Therefore, you should return null if there is no query/userinfo.

Thank you, I realized I read the wrong part. I will delete the topic not to confuse people.

Please keep the topic up so that other people who also misread can find this quickly and resolve their issue.

1 Like