query1:
class MWC202 {
public static void main (
String[] args) {
StringBuffer sb1 = new StringBuffer("ABC");
StringBuffer sb2 = new StringBuffer("ABC");
System.out.print((sb1==sb2)+","+sb1.equals(sb2));
}}
answer is:false,false.
but string buffer is does not override equals , so it should have given a compile time error
please explain
Query 2:
class GFC304 {
static void m1(int[] i1, int[] i2) {
int[] i3 = i1; i1 = i2; i2 = i3;
}
public static void main (String[] args) {
int[] i1 = {1}, i2 = {3}; m1(i1, i2);
System.out.print(i1[0] + "," + i2[0]);
}}
will it swap the value ?if not then please explain