Comparing two StringBuilders
Predict the outputMediumJava only
public class Main {
public static void main(String[] args) {
StringBuilder a = new StringBuilder("abc");
StringBuilder b = new StringBuilder("abc");
System.out.println(a.equals(b));
System.out.println(a.toString().equals(b.toString()));
StringBuilder r = a.reverse();
System.out.println(r);
System.out.println(a);
System.out.println(r == a);
}
}
This question is part of Pro+
Pro+ opens every question in Interview Prep and the mock interview. Every article and the first 2 questions of each topic stay free. Hands-on Selenium and API tasks follow their course lesson's own lock.