Developer community
0 votes
16.7k views
asked by Guru (24.6k points) 30 54 84 | 16.7k views

1 Answer

0 votes
 
The following code passes objects to methods.
 
 
class Test {
  int a;
 
  Test(int i) {
    a = i;
  }
  boolean equals(Test o) {
    if (o.a == a )
      return true;
    else
      return false;
  }
}
 
public class Main {
  public static void main(String args[]) {
    Test ob1 = new Test(100);
    Test ob2 = new Test(100);
 
    System.out.println("ob1 == ob2: " + ob1.equals(ob2));
 
  }
}
 
 
answered by Sr Member (5k points) 7 9 12

Related questions

0 votes
1 answer
asked by augustaina Sr Member (4.8k points) 10 25 31 | 91 views
0 votes
1 answer
asked by sara Guru (24.6k points) 30 54 84 | 13 views
0 votes
1 answer
asked by sara Guru (24.6k points) 30 54 84 | 19 views
0 votes
1 answer
asked by augustaina Sr Member (4.8k points) 10 25 31 | 94 views
0 votes
1 answer
asked by augustaina Sr Member (4.8k points) 10 25 31 | 102 views
Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true

Categories


C Books Guide and List
C++ Books Guide and List
Best Java Books

3.8k questions

4k answers

117 comments

10.7k users

3,751 questions
4,046 answers
117 comments
10,709 users