1 / 18

Advanced Programming in Java

Advanced Programming in Java. Sadegh Aliakbary Sharif University of Technology Fall 2010. Agenda. Type Checking Type Casting Type Conversion toString () method equals() method . Type Safety. The Java language is designed to enforce type safety

pelham
Download Presentation

Advanced Programming in Java

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Advanced Programming in Java SadeghAliakbary Sharif University of Technology Fall 2010

  2. Agenda • Type Checking • Type Casting • Type Conversion • toString() method • equals() method Sharif University of Technology

  3. Type Safety • The Java language is designed to enforce type safety • Accessing memory in inappropriate ways is banned • Every piece of memory is part of some Java object • Each object has some class • Because of • No Pointer • Strong Type Checking Sharif University of Technology

  4. Java Type Checking • Java has a strong type checking mechanism Sharif University of Technology

  5. Primitive Types Sharif University of Technology

  6. Type Checking Special Cases • Reference-type to primitive type and vise versa Sharif University of Technology

  7. Type Checking in Method Calls Sharif University of Technology

  8. Type Casting • You can change the type by type casting • Casting in reference types and other objects is not so simple • See it later Sharif University of Technology

  9. Type Conversion • Sometimes we want to convert an object to another type • Type casting is not the solution here • We should write some methods to convert the types Sharif University of Technology

  10. Type Conversion (2) Sharif University of Technology

  11. toString • toString() is a special method • You can write it for every class Sharif University of Technology

  12. Sharif University of Technology

  13. Checking equality in java Sharif University of Technology

  14. equals method Sharif University of Technology

  15. Parameter Passing • Call by value • Call by reference • Java style : Call by passing value of references! • Let’s see! Sharif University of Technology

  16. Quiz! • Write a java class for representing … Sharif University of Technology

  17. Sharif University of Technology

  18. Sharif University of Technology

More Related