Sadegh Aliakbary Sharif University of Technology Fall 2010.

Slides:



Advertisements
Similar presentations
Packages Sudhir Talasila Preeti Navale. Introduction Packages are nothing more than the way we organize files into different directories according to.
Advertisements

Sadegh Aliakbary Sharif University of Technology Fall 2010.
PACKAGES. PACKAGES IN JAVA A package is a collection of related classes and interfaces in Java Packages help in logical grouping of classes and interfaces.
Chapter 3 - Java Programming With Supplied Classes1 Chapter 3 Java Programming With Supplied Classes.
Road Map Introduction to object oriented programming. Classes
Slides prepared by Rose Williams, Binghamton University Chapter 14 Generics and the ArrayList Class.
Slides prepared by Rose Williams, Binghamton University Chapter 5 Defining Classes II.
Abstract Data Types and Encapsulation Concepts
1 CSE 331 Java Packages; JAR Archives slides created by Marty Stepp based on materials by M. Ernst, S. Reges, D. Notkin, R. Mercer, Wikipedia
Sadegh Aliakbary Sharif University of Technology Fall 2010.
Principles of Computer Programming (using Java) Review Haidong Xue Summer 2011, at GSU.
PACKAGES Mimi OpkinsCECS277. What We’ll Cover  Packages and Import Statements  The Package java.lang  Package Names and Directories  The Default Package.
Overview of Previous Lesson(s) Over View  OOP  A class is a data type that you define to suit customized application requirements.  A class can be.
Sadegh Aliakbary Sharif University of Technology Fall 2010.
Presented by: Mojtaba Khezrian. Agenda Object Creation Object Storage More on Arrays Parameter Passing For Each VarArgs Spring 2014Sharif University of.
Object Oriented Programming in Java Habib Rostami Lecture 5.
More with Methods (parameters, reference vs. value, array processing) Corresponds with Chapters 5 and 6.
Recap (önemli noktaları yinelemek) from last week Paradigm Kay’s Description Intro to Objects Messages / Interconnections Information Hiding Classes Inheritance.
Lecture Set 11 Creating and Using Classes Part B – Class Features – Constructors, Methods, Fields, Properties, Shared Data.
Sadegh Aliakbary. Copyright ©2014 JAVACUP.IRJAVACUP.IR All rights reserved. Redistribution of JAVACUP contents is not prohibited if JAVACUP.
Methods in Java. Program Modules in Java  Java programs are written by combining new methods and classes with predefined methods in the Java Application.
Peyman Dodangeh Sharif University of Technology Fall 2013.
Sadegh Aliakbary Sharif University of Technology Spring 2011.
Defining Classes II. Today’s topics  Static methods  Static variables  Wrapper classes  References  Class parameters  Copy constructor.
Classes Definition A class is a data type whose variables are objects Object – a variable that has member functions as well the ability to hold.
CSS446 Spring 2014 Nan Wang.  A Java program consists of a collection of classes.  Package is a set of related classes. 2.
Introduction to Java Chapter 7 - Classes & Object-oriented Programming1 Chapter 7 Classes and Object-Oriented Programming.
Sadegh Aliakbary Sharif University of Technology Fall 2010.
Functions in C CSE 2451 Rong Shi. Functions Why use functions? – Reusability Same operation, different data – Abstraction Only need to know how to call.
Sadegh Aliakbary Sharif University of Technology Spring 2011.
Sadegh Aliakbary Sharif University of Technology Fall 2012.
CMSC 341 Java Packages, Classes, Variables, Expressions, Flow Control, and Exceptions.
CS-1030 Dr. Mark L. Hornick 1 Basic C++ State the difference between a function/class declaration and a function/class definition. Explain the purpose.
1 CS161 Introduction to Computer Science Topic #16.
More on Objects Mehdi Einali Advanced Programming in Java 1.
Sadegh Aliakbary. Copyright ©2014 JAVACUP.IRJAVACUP.IR All rights reserved. Redistribution of JAVACUP contents is not prohibited if JAVACUP.
Peyman Dodangeh Sharif University of Technology Spring 2014.
Duke CPS From C++ to Java l Java history: Oak, toaster-ovens, internet language, panacea l What it is ä O-O language, not a hybrid (cf. C++)
Peyman Dodangeh Sharif University of Technology Spring 2014.
Packages. Access Specifications Public Available anywhere (public keyword) Only one public class per file allowed Protected Available in subclasses, and.
1 Chapter 6 Programming with Objects and Classes F OO Programming Concepts F Creating Objects and Object Reference Variables –Differences between primitive.
Packages. The main feature of OOP is its ability to support the reuse of code: –Extending the classes –Extending interfaces The features in basic form.
Chapter 4: More Object Concepts. Objectives Understand blocks and scope Overload a method Avoid ambiguity Create and call constructors with parameters.
SourceAnatomy1 Java Source Anatomy Barb Ericson Georgia Institute of Technology July 2008.
Sadegh Aliakbary Sharif University of Technology Fall 2010.
Structured Programming Dr. Atif Alhejali Lecture 4 Modifiers Parameters passing 1Structured Programming.
(C) 2010 Pearson Education, Inc. All rights reserved.  Best way to develop and maintain a large program is to construct it from small, simple pieces,
Today Javadoc. Packages and static import. Viewing API source code. Upcoming Topics: –protected access modifier –Using the debugger in Eclipse –JUnit testing.
Objects and Memory Mehdi Einali Advanced Programming in Java 1.
Sadegh Aliakbary Sharif University of Technology Fall 2010.
Haidong Xue Summer 2011, at GSU
Packages When we name a program , we name it by class name…
Java Basics Packages.
Advanced Programming in Java
Advanced Programming Behnam Hatami Fall 2017.
Advanced Programming in Java
Defining Classes II.
Pass by Reference, const, readonly, struct
Corresponds with Chapter 7
Object Oriented Programming in java
CISC124 Assignment 3 due tomorrow at 7pm.
Assessment – Java Basics: Part 1
Java Programming Language
Using java libraries CGS3416 spring 2019.
Chapter 6 Objects and Classes
Classes 5/5 May 14, 2019 ICS102: Classes 5/5.
CMPE212 – Reminders Assignment 2 due today, 7pm.
Advanced Programming in Java
Presentation transcript:

Sadegh Aliakbary Sharif University of Technology Fall 2010

Agenda Method Call Call by value & reference Variable argument lists For each Packages Fall 2010Sharif University of Technology2

Parameter Passing Call by value Call by reference Java style : Call by passing value of references! Let’s see! Fall 2010Sharif University of Technology3

What happens in a method call Fall 2010Sharif University of Technology4

Swap Fall 2010Sharif University of Technology5

Swap (2) Fall 2010Sharif University of Technology6

Call by reference in C++ Fall 2010Sharif University of Technology7

Call by reference in C# Fall 2010Sharif University of Technology8

In java Everything is passed by value Primitive-types are passed by value References are passed by value If you want to pass something by reference… Wrap it in an object Fall 2010Sharif University of Technology9

Fall 2010Sharif University of Technology10

For Each Fall 2010Sharif University of Technology11

For Each (2) In for each expression, each element is assigned to another variable If X is a primitive type, element values are copied into item variable Fall 2010Sharif University of Technology12

Quiz! Fall 2010Sharif University of Technology13

Fall 2010Sharif University of Technology14

Variable argument lists Fall 2010Sharif University of Technology15

Variable argument lists Called as vararg in C++ Varargs are actually arrays Fall 2010Sharif University of Technology16

Package A package contains a group of classes Organized together under a single namespace Packages organize classes belonging to the same category or providing similar functionality A package provides a unique namespace for the types it contains Classes in one package has the same folder Packages may contain other packages Hierarchy of packages Fall 2010Sharif University of Technology17

Some famous java packages java.util java.lang java.io Fall 2010Sharif University of Technology18

Java Packages import keyword Class Qualified Name = package-name + class-name For example java.lang.String java.lang.Math double sqrt = Math.sqrt(123); java.util.Scanner java.awt.Event org.w3c.dom.events.Event Fall 2010Sharif University of Technology19

Write a packaged java project Lets write … Fall 2010Sharif University of Technology20

Package Access Remember public and private access specifiers The default access has no keyword It is commonly referred to as package access and sometimes friendly Other classes in the current package have access to that member To classes outside of this package, the member appears to be private. Fall 2010Sharif University of Technology21

Exceptions Fall 2010Sharif University of Technology22

Fall 2010Sharif University of Technology23