Hercles Posted March 30, 2015 at 10:40 PM Report Share #580529 Posted March 30, 2015 at 10:40 PM Olá! caros, estava estudando um código e me deparei com a seguinte notação: String tel = (String)d.Consulta("joao"); Este => (String) entre parêntese faz o que? Link to comment Share on other sites More sharing options...
KTachyon Posted March 30, 2015 at 11:32 PM Report Share #580534 Posted March 30, 2015 at 11:32 PM Faz o cast do objecto devolvido para String. Se o objecto devolvido não for uma String (ou uma subclasse de String), se tentares chamar uma função sobre essa variável o programa vai crashar. “There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult.” -- Tony Hoare Link to comment Share on other sites More sharing options...
Hercles Posted March 31, 2015 at 09:50 AM Author Report Share #580564 Posted March 31, 2015 at 09:50 AM Certo. Deve ser o mesmo que acontece nesse código abaixo: do { try { i = fi.read(); } catch (IOException e) { System.out.println(" O arquivo não pode ser lido!"); } if(i != -1) System.out.print((Char) i); // cast ??? } while (i != -1); } } Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now