1
Hello, I was studying HTTP Requests in Java when I came across a code and in a certain line there was a statement a little bit strange to me, someone can explain to me what a type means before a statement?
HttpURLConnection connection = null;
URL url = new URL(targetURL);
connection = (HttpURLConnection) url.openConnection(); //Esta declaração
Excuse the ignorance on the subject, but can someone explain to me why of type Httpurlconnection before the rest of the designation? Thanks in advance!
This is called a cast, it is used to convert a value type to another type, in which case it is converting the URL type into Httpurlconnection
– Edjane
Thanks friend, I do not like very much to copy and paste without understanding the code! You helped me too much! Hug.
– Matheus Grossi