Why is Integer.parseint() used when we have type casting?
Maybe another way to ask this question would be:
When should Integer.parseint() be used over type casting?
Type casting is used to make object of one type assign to other without altering or parsing the contents of the object. While parseInt method parses the String values and converts it to integer value i.e. converts String value to integer.
Type casting has nothing to do with contents of the object. It is only used for assigning reference type of one type to another.
Eg : Object obj = new String(""); String string = (String) obj;