Bellow I have some code and I was interested in understanding why this method works when it is static? I expected the opposite
public class demo { int no; demo(int no){ this.no=no; } public static void swap(demo c1, demo c2) { int temp = c1.no; c1.no = c2.no; c2.no = temp; } public static void main(String args[]) { demo c1 = new demo(1); demo c2 = new demo(2); swap(c1, c2); System.out.println("c1.no = " + c1.no); System.out.println("c2.no = " + c2.no); } }