I still cannot fully understand this static and non static.
public static void main(String args[]){ staticClass.setString("hey there"); System.out.println(staticClass.getString2()); //expecting to be blank NonStaticCalling nonStaticCalling = new NonStaticCalling(); } static String aw = ""; public static void setString(String a){ aw =a; } public String getString(){ return aw; } public static String getString2(){ return aw; } public class NonStaticCalling { staticClass staticClass = new staticClass(); public NonStaticCalling(){ staticClass.getString(); System.out.println(staticClass.getString()); } } If i understand correctly. I declare a new object nonstaticcalling. So i assume that the value of the output from that class is "" (blank)
Can someone give me a better exmaple? thanks