I have very basic java question but tutorials are not focusing on this aspect. If anyone can describe for what we use this kind of brackets.
First example Employee in brackets:
Employee e = null;
try
{
FileInputStream fileIn = new FileInputStream("/tmp/employee.ser");
ObjectInputStream in = new ObjectInputStream(fileIn);
e = (Employee) in.readObject(); <=========== (Employee)
in.close();
fileIn.close();
}
Second example:
InputStream fileIs = null;
ObjectInputStream objIs = null;
try {
fileIs = new FileInputStream("MyEmpFile.txt");
objIs = new ObjectInputStream(fileIs);
Employee emp = (Employee) objIs.readObject(); <========== (Employee)
System.out.println(emp);
}
I understand what:
Employee emp = new Employee();
does but with this brackets (Employee) inside I don't get it. What is this?
I asked this question here becouse google searches with combined queries like "java brackets before constructor", "java brackets creating new objects" etc didn't find results from which I could gather information about my questions. I've read java tutorials too, all were without pointing this example.
(For example www.tutorialspoint.com/java/index.htm )
Thank you for your time! I hope I will be able to help other members in the future.