180 likes | 314 Views
This agenda covers essential concepts in advanced Java programming as part of the Fall 2010 course at Sharif University of Technology. Key topics include type checking, casting, conversion, and the behavior of the `toString()` and `equals()` methods. The emphasis is on Java's type safety, strong type checking mechanisms, and the distinctions between primitive and reference types. Additionally, it explores parameter passing techniques and provides practical examples to solidify understanding. Learners will engage with quizzes and coding challenges to apply their knowledge.
E N D
Advanced Programming in Java SadeghAliakbary Sharif University of Technology Fall 2010
Agenda • Type Checking • Type Casting • Type Conversion • toString() method • equals() method Sharif University of Technology
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
Java Type Checking • Java has a strong type checking mechanism Sharif University of Technology
Primitive Types Sharif University of Technology
Type Checking Special Cases • Reference-type to primitive type and vise versa Sharif University of Technology
Type Checking in Method Calls Sharif University of Technology
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
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
Type Conversion (2) Sharif University of Technology
toString • toString() is a special method • You can write it for every class Sharif University of Technology
Checking equality in java Sharif University of Technology
equals method Sharif University of Technology
Parameter Passing • Call by value • Call by reference • Java style : Call by passing value of references! • Let’s see! Sharif University of Technology
Quiz! • Write a java class for representing … Sharif University of Technology