Whenever we are passing data to any url or web services, some characters of the data might be un recognised. Hence, it is always better to encode data before sending to URLs or web services, which we call as URL encoding. We have pre defined apis in java to do this encoding.
Below is an example to show how to encode a string in java.
String str=”Hello World”;
The output for this code would be: