Android/Java Instantiating a class multiple times -
i'm using sugarorm sqlite in android app. using code below add new rows table:
mytable d = new mytable("row1_title",valuerow1,stockrow1); d.save(); mytable d2 = new mytable("row2_title",valuerow2,stockrow2); d2.save(); mytable d3 = new mytable("row3_title",valuerow3,stockrow3); d3.save(); mytable d4 = new mytable("row4_title",valuerow4,stockrow4); d4.save(); mytable d5 = new mytable("row5_title",valuerow5,stockrow5); d5.save(); mytable d6 = new mytable("row6_title",valuerow6,stockrow6); d6.save(); mytable d7 = new mytable("row7_title",valuerow7,stockrow7); d7.save();
mytable constructor
public mytable(string title, int value, int stock){ this.title = title; this.value = value; this.stock = stock; }
this works fine, right way instantiate class multiple times? seems should able combine instantiating in way?
thanks
not really. if want initialize different variables different parameters in constructor way it.
there other things can do, involve changing other parts of code , aren't more simple (ex: making array of mytable
objects).
Comments
Post a Comment