This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public native int hashCode(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Contact { | |
| private String name; | |
| private String phone; | |
| public Contact(String name, String phone) { | |
| this.name = name; | |
| this.phone = phone; | |
| } | |
| public boolean equals(Object contact) { | |
| Contact anotherContact = (Contact)contact; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Contact { | |
| private String name; | |
| private String phone; | |
| public Contact(String name, String phone) { | |
| this.name = name; | |
| this.phone = phone; | |
| } | |
| @Override | |
| public boolean equals(Object contact) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public boolean equals(Object obj) { | |
| return (this == obj); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Contact { | |
| private String name; | |
| private String phone; | |
| public Contact(String name, String phone) { | |
| this.name = name; | |
| this.phone = phone; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public boolean equals(Object anObject) { | |
| if (this == anObject) { | |
| return true; | |
| } | |
| if (anObject instanceof String) { | |
| String anotherString = (String)anObject; | |
| int n = value.length; | |
| if (n == anotherString.value.length) { | |
| char v1[] = value; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Test { | |
| public static void main(String[] args) { | |
| String s1 = new String("Anish"); | |
| String s2= new String("Anish"); | |
| System.out.println(s1.equals(s2)); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Test { | |
| public static void main(String[] args) { | |
| int x = 4; | |
| StringBuffer sb = new StringBuffer("..fedcba"); | |
| sb.delete(3, 6); | |
| sb.insert(3, "az"); | |
| if (sb.length() > 6) | |
| x = sb.indexOf("b"); | |
| sb.delete((x - 3), (x - 2)); | |
| System.out.println(sb); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Test { | |
| public static void main(String[] args) { | |
| String s = "-"; | |
| Integer x = 343; | |
| long L343 = 343L; | |
| if (x.equals(L343)) | |
| s += ".e1 "; | |
| if (x.equals(343)) | |
| s += ".e2 "; | |
| Short s1 = (short) ((new Short((short) 343)) / (new Short((short) 49))); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Test { | |
| public static void main(String[] args) { | |
| Long xL = new Long(456L); | |
| long x1 = Long.valueOf("123"); | |
| Long x2 = Long.valueOf("123"); | |
| long x3 = xL.longValue(); | |
| Long x4 = xL.longValue(); | |
| Long x5 = Long.parseLong("456"); | |
| long x6 = Long.parseLong("123"); | |
| } |