Can anybody please help explain why the output is not giving the proper result? Is this a semantic error?
public class Programming1Practice { /* testing out instantiation and object oriented programming */ public static class staticValues { static int num1 = 0; int num2; } public static void main(String[] args) { staticValues s1 = new staticValues(); s1.num1 = 10; s1.num2 = 9; staticValues s2 = new staticValues(); staticValues s3 = new staticValues(); s3.num1 = 8; s3.num2 = 2; System.out.println("num1 = " + s1 + "num2 = " + s2); } }
the output is:
run:
num1 = programming1practice.Programming1Practice$staticVa lues@2f995c9anum2 = programming1practice.Programming1Practice$staticVa lues@7d8e9adf
BUILD SUCCESSFUL (total time: 1 second)