Core Java
Core Java Core Java String Concepts HashCode & Equal Methods Immutability OOPS Concepts Abstraction Encapsulation Polymorphism Inheritance String Concepts A String is a sequence of characters. How to create a String object? String literal String s1="Welcome"; String s2="Welcome";//It doesn't create a new instance New keyword String s=new String("Welcome"); //creates object and reference variable Examples:- String s1 = "Hello"; char ch[] = {'H', 'e', 'l', 'l', 'o'}; String s2 = new String(ch); String s3 = "Hello"; String s4 = new String("Hello"); String s5 = new String("Hello"); System.out.println(s1 == s2); // false System.out.println(s1 == s3); // true System.out.println(s4 == s5); // false HashCode & Equal Methods Default implementations of equals() and hashcode() methods: ...