« Back
package com.string; public class JavaStringPool { public static void main(String[] args) { String s1 = "coders"; String s2 = "arts"; String s3 = "coders"; if (s1==s3) { System.out.println("Both string refer to the same object"); } //different reference if (s1==s2) { System.out.println("Both strings refer to the same object"); }else { System.out.println("Both strings refer to the different object"); } } }
Both string refer to the same object
Both strings refer to the different object
×
Report a Problem:
Description:
Submit