Skip to content

Commit 4a5ebf8

Browse files
equal method in java
1 parent 514a23a commit 4a5ebf8

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

equals method

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
2+
3+
//remember in this programe i not used funcation for the equal
4+
class hardik
5+
{
6+
String car;
7+
int speed;
8+
9+
hardik(String a,int b)
10+
{
11+
this.car=a;
12+
this.speed=b;
13+
}
14+
15+
}
16+
public class equals {
17+
18+
public static void main(String[] args)
19+
{
20+
//this statement give the default false value because we are take object within the same class
21+
22+
//all the value are the same
23+
// hardik obj1= new hardik("charger",230);
24+
// hardik obj2= new hardik("charger",230);
25+
26+
//value is different
27+
28+
hardik obj1= new hardik("mustang",230);
29+
hardik obj2= new hardik("charger",230);
30+
31+
System.out.println(obj1.equals(obj2));
32+
}
33+
}

0 commit comments

Comments
 (0)