I have recently been learning Java and trying to work with classes. But I am not able to start array objects
class tablets {string s = null; Zero set (string A) {s = a; }} Public class questions {public static zero main (string array []) {tablet [] t = new tablet [6]; For (int i = 0; i
Can anyone tell me where I am going?
when you do
tablet << T> new tablet [6];
You are creating the array of references (i.e. the array of reference variables) , which are not pointing elsewhere i.e. they are zero. You need to set the objects above. Reference variables were created in the array.
Tablet [] T = new tablet [6]; For (int i = 0; i <6; i ++) {t [i] = new tablet (); T [i] .Set ("111"); // no tap pointer exception no longer}
No comments:
Post a Comment