Define an array object in java -


i found class declaration works me, wonder if class written more "short":

public class data implements comparable <data>{     public data     (int category,  string quality, string title ) {         super();         this.category = category;         this.quality = quality;         this.title = title;     }     int    category;     string quality;     string title;      @override     public int compareto(data d) {        return this.getduration_value() - (d.getduration_value());     } } 

why have mention "category, quality title" ? , why "super()" ? have shorter. found other explanations, "complex structure".

the "data" given these lines, , want not have declare in advance length of array:

data[] mydataarray = {          new data(0,                 // category "0"                 "***",              // quality                 "mytitle1")         // title          new data(0,                 // same category "0"                 "**",               // quality                 "mytitle2")         // title } 

super() invokes parent class constructor. if skip this, java invoke default constructor (with no arguments) automatically, can skip line in example.

array's length should declared in advance. if problem, should use container such arraylist instead. arraylist automatically resize when needed.

as mentioning fields multiple times, java verbose.


Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -