References, Objects, and Parameter Passing

Slides:



Advertisements
Similar presentations
Continuation of chapter 6…. Nested while loop A while loop used within another while loop is called nested while loop. Q. An illustration to generate.
Advertisements

1 Classes and Objects in Java Parameter Passing, Delegation, Visibility Control, and Object Cleanup.
For(int i = 1; i
Loops –Do while Do While Reading for this Lecture, L&L, 5.7.
Passing information through Parameters ( our setter methods or mutators) Formal Parameter – parameter in the method. public void SetA(int x){ (int x) is.
Josephus Problem: Build the Circular Linked List
Do You Understand Methods and Parameters? In this section you will be shown 25 different programs. Most of these programs have some type of error. A few,
Ics202 Data Structures. class Array { protected Object[] data; protected int base; public Array (int n, int m) { data = new Object[n]; base = m; } public.
Logical OperatorstMyn1 Logical Operators Using logical operators, we can combine a series of comparisons into a single expression. if(letter>=‘A’ && letter
CSI1390 – Java Programming Methods II Instructor: Saeid Nourian
Indentation & Readability. What does this program do? public class Hello { public static void main ( String[] args ) { //display initial message System.out.println(
ICBT  Basura Ramanayaka  Eshani werapitiya  Hasitha Dananjaya.
The Assignment operator tMyn1 The Assignment Operator The result of a calculation can be stored in a variable using the assignment operator =. Because.
Take out a piece of paper and PEN. The quiz starts ONE minute after the tardy bell rings. You will have 45 – 90 seconds per question. Determine the output.
FOR LOOP WALK THROUGH public class NestedFor { public static void main(String [] args) { for (int i = 1; i
Java and C++ Transitioning. A simple example public class HelloWorldApp { public static void main(String[] args) { //Display the string. System.out.println("Hello.
TOPIC 6 Methods F Introducing Methods F Declaring Methods F Calling Methods F Passing Parameters F Pass by Value F Overloading Methods F Method Abstraction.
Java Programming Final Keyword In Java. final keyword The final keyword in java is used to restrict the user. The final keyword can be used in many context.
Chapter 5 : Methods Part 2. Returning a Value from a Method  Data can be passed into a method by way of the parameter variables. Data may also be returned.
Array Size Arrays use static allocation of space. That is, when the array is created, we must specify the size of the array, e.g., int[] grades = new int[100];
AP Computer Science A – Healdsburg High School 1 Unit 9 - Parameter Passing in Java.
CS001 Introduction to Programming Day 6 Sujana Jyothi
import java.util.Scanner; class myCode { public static void main(String[] args) { Scanner input= new Scanner(System.in); int num1; System.out.println(“Enter.
Computer Science A 1. Course plan Introduction to programming Basic concepts of typical programming languages. Tools: compiler, editor, integrated editor,
Methods What is a method? Main Method the main method is where a stand alone Java program normally begins execution common compile error, trying.
Output Programs These slides will present a variety of small programs. Each program has a compound condition which uses the Boolean Logic that was introduced.
WAP to find out the number is prime or not Import java.util.*; Class Prime { public static void main(string args[]) { int n,I,res; boolean flag=true;
JAVA METHODS (FUNCTIONS). Why are they called methods? Java is a strictly object-oriented programming language Methods are functions inside of objects.
Mark Fontenot CSE Honors Principles of Computer Science I Note Set 7.
Import javax.swing.JOptionPane; public class Rectangle { public static void main(String[] args) { double width, length, area, perimeter; String lengthStr,
Staples are our staple Building upon our solution.
Methods Matthew Harrison. Overview ● There are five main aspects of methods... ● 1) Modifiers – public, private ● 2) Method Name ● 3) Parameters ● 4)
Chapter 2 Clarifications
Department of Computer Science
התוכנית: using System; using System.Collections.Generic;
using System; namespace Demo01 { class Program
Building Java Programs
Function Call Trace public class Newton {
Something about Java Introduction to Problem Solving and Programming 1.
Decision statements. - They can use logic to arrive at desired results
Functions Used to write code only once Can use parameters.
Computing Adjusted Quiz Total Score
TO COMPLETE THE FOLLOWING:
חלק ה שימוש במציין שלם לערך תווי
Propositional Equivalences Rosen 5th and 6th Editions section 1.2
محاور المحاضرة خوارزمية الفقاعات الهوائية (Bubble Sort)
Assignment 7 User Defined Classes Part 2
Code Animation Examples
Method Overloading in JAVA
Recursive GCD Demo public class Euclid {
JAVA Constructors.
References and Objects
class PrintOnetoTen { public static void main(String args[]) {
Java Programming with Multiple Classes
Why did the programmer quit his job?
A Java Application public class Hello { public static void main(String [] args) { System.out.println("Hello, World!"); } } public class.
if-else if (condition) { statements1 } else { statements2
Scope of variables class scopeofvars {
A Java Application public class Hello { public static void main(String [] args) { System.out.println("Hello, World!"); } } public class.
while while (condition) { statements }
Scope scope: The part of a program where a variable exists. From its declaration to the end of the { } braces A variable declared in a for loop exists.
Developing Java Applications with NetBeans
Recursion Method calling itself (circular definition)
Developing Java Applications with NetBeans
Consider the following code:
Methods/Functions.
CIS 110: Introduction to Computer Programming
CPSC 233 Tutorial 13 March 11/12th, 2015.
Instructor: Mainak Chaudhuri
Presentation transcript:

References, Objects, and Parameter Passing Data Structures

public class X { public int value; public static void bah(X d, X e) { X f = d; f.value = f.value+1; X g = new X(); g.value = e.value+1; e = g; } public static void main(String args[]) { X a = new X(); a.value = 1; X b = new X(); b.value = 10; X c = a; c.value = 5; bah(a,b); System.out.println(a.value + ", " + b.value + ", " + c.value);} }

public class X { public int value; public static void bah(X d, X e) { X f = d; f.value = f.value+1; X g = new X(); g.value = e.value+1; e = g; } public static void main(String args[]) { X a = new X(); a.value = 1; X b = new X(); b.value = 10; X c = a; c.value = 5; bah(a,b); System.out.println(a.value + ", " + b.value + ", " + c.value);} }

public class X { public int value; public static void bah(X d, X e) { X f = d; f.value = f.value+1; X g = new X(); g.value = e.value+1; e = g; } public static void main(String args[]) { X a = new X(); a.value = 1; X b = new X(); b.value = 10; X c = a; c.value = 5; bah(a,b); System.out.println(a.value + ", " + b.value + ", " + c.value);} }

public class X { public int value; public static void bah(X d, X e) { X f = d; f.value = f.value+1; X g = new X(); g.value = e.value+1; e = g; } public static void main(String args[]) { X a = new X(); a.value = 1; X b = new X(); b.value = 10; X c = a; c.value = 5; bah(a,b); System.out.println(a.value + ", " + b.value + ", " + c.value);} }

public class X { public int value; public static void bah(X d, X e) { X f = d; f.value = f.value+1; X g = new X(); g.value = e.value+1; e = g; } public static void main(String args[]) { X a = new X(); a.value = 1; X b = new X(); b.value = 10; X c = a; c.value = 5; bah(a,b); System.out.println(a.value + ", " + b.value + ", " + c.value);} }

public class X { public int value; public static void bah(X d, X e) { X f = d; f.value = f.value+1; X g = new X(); g.value = e.value+1; e = g; } public static void main(String args[]) { X a = new X(); a.value = 1; X b = new X(); b.value = 10; X c = a; c.value = 5; bah(a,b); System.out.println(a.value + ", " + b.value + ", " + c.value);} }

public class X { public int value; public static void bah(X d, X e) { X f = d; f.value = f.value+1; X g = new X(); g.value = e.value+1; e = g; } public static void main(String args[]) { X a = new X(); a.value = 1; X b = new X(); b.value = 10; X c = a; c.value = 5; bah(a,b); System.out.println(a.value + ", " + b.value + ", " + c.value);} }

public class X { public int value; public static void bah(X d, X e) { X f = d; f.value = f.value+1; X g = new X(); g.value = e.value+1; e = g; } public static void main(String args[]) { X a = new X(); a.value = 1; X b = new X(); b.value = 10; X c = a; c.value = 5; bah(a,b); System.out.println(a.value + ", " + b.value + ", " + c.value);} }

public class X { public int value; public static void bah(X d, X e) { X f = d; f.value = f.value+1; X g = new X(); g.value = e.value+1; e = g; } public static void main(String args[]) { X a = new X(); a.value = 1; X b = new X(); b.value = 10; X c = a; c.value = 5; bah(a,b); System.out.println(a.value + ", " + b.value + ", " + c.value);} }

public class X { public int value; public static void bah(X d, X e) { X f = d; f.value = f.value+1; X g = new X(); g.value = e.value+1; e = g; } public static void main(String args[]) { X a = new X(); a.value = 1; X b = new X(); b.value = 10; X c = a; c.value = 5; bah(a,b); System.out.println(a.value + ", " + b.value + ", " + c.value);} }

public class X { public int value; public static void bah(X d, X e) { X f = d; f.value = f.value+1; X g = new X(); g.value = e.value+1; e = g; } public static void main(String args[]) { X a = new X(); a.value = 1; X b = new X(); b.value = 10; X c = a; c.value = 5; bah(a,b); System.out.println(a.value + ", " + b.value + ", " + c.value);} }

public class X { public int value; public static void bah(X d, X e) { X f = d; f.value = f.value+1; X g = new X(); g.value = e.value+1; e = g; } public static void main(String args[]) { X a = new X(); a.value = 1; X b = new X(); b.value = 10; X c = a; c.value = 5; bah(a,b); System.out.println(a.value + ", " + b.value + ", " + c.value);} }

public class X { public int value; public static void bah(X d, X e) { X f = d; f.value = f.value+1; X g = new X(); g.value = e.value+1; e = g; } public static void main(String args[]) { X a = new X(); a.value = 1; X b = new X(); b.value = 10; X c = a; c.value = 5; bah(a,b); System.out.println(a.value + ", " + b.value + ", " + c.value);} }

public class X { public int value; public static void bah(X d, X e) { X f = d; f.value = f.value+1; X g = new X(); g.value = e.value+1; e = g; } public static void main(String args[]) { X a = new X(); a.value = 1; X b = new X(); b.value = 10; X c = a; c.value = 5; bah(a,b); System.out.println(a.value + ", " + b.value + ", " + c.value);} }

public class X { public int value; public static void bah(X d, X e) { X f = d; f.value = f.value+1; X g = new X(); g.value = e.value+1; e = g; } public static void main(String args[]) { X a = new X(); a.value = 1; X b = new X(); b.value = 10; X c = a; c.value = 5; bah(a,b); □ System.out.println(a.value + ", " + b.value + ", " + c.value);} }

public class X { public int value; public static void bah(X d, X e) { X f = d; f.value = f.value+1; X g = new X(); g.value = e.value+1; e = g; } public static void main(String args[]) { X a = new X(); a.value = 1; X b = new X(); b.value = 10; X c = a; c.value = 5; bah(a,b); System.out.println(a.value + ", " + b.value + ", " + c.value);} }