 constructor, just with the exception that instead of using the local variables (passed as arguments), we use the Rectangle instance's field values instead (e.g. this.width instead of w).
Maybe your instructor explicitly wanted you to override the #toString() method, and inside the overridden method, you'd have your logic for printing the Rectangle. If that is the case, you'd of course just move the logic from the #printRectangle() to the overridden #toString() method, which would allow you to use System.out.println(box1) (replace the previous sampled #toString() method, of course).
@Override
public String toString() {
    // Logic from #printRectangle() here
}

If you choose to override #toString(), you should not use System.out.println in the logic, but rather build a string, which you'll return at the end of the #toString() logic. You could take a look at StringBuilder for this.

 Q:

Nullpointer exception error for using split and comma operators

I want to store the values HTRANS and HBURST in one list and 2'b00 and 3'b000 in another list. But i am getting a null pointer exception in the code which i have written, I have written an SSCCE for the same, please help.
import java.util.ArrayList;
import java.util.List;

public class SSCCE1 {
    public static void main(String[] args) {
        List<String> bins = new ArrayList<String>();
        bins.add("HTRANS = 2'b00 to 2'b11");
        bins.add("HTRANS = 2'b00 to 2'b11, HBURST = 3'b000 to 3'b111");
        String[] bins_splitcomma = null;
        String temp;
        for(int i =0; i < bins.size(); i++) {
            temp = bins.get(i);
            if(temp.contains(",")) {                // if element of bins contains comma, case 2.
                bins_splitcomma = temp.split(",");
            }
            else {
                bins_splitcomma[0] = temp;          // if element of bins does not contain a comma, case 1.
            }

        }

constructor, just with the exception that instead of using the local variable star (guide as arguments), we use the Rectangle instance's discipline values instead (for example this.width instead of w). 
 Maybe your instructor explicitly desire you to override the # toString () method, and inside the overridden method acting, you'd have your logic for printing the Rectangle. If that is the case, you'd of course barely move the logic from the # printRectangle () to the overridden # toString () method, which would allow you to use System.out.println(box1) (replace the former sampled # toString () method, of course). 
 @Override 
 public String toString () { 
     // Logic from # printRectangle () here 
 } 

 If you choose to overrule # toString (), you should not use System.out.println in the logic, but rather build a string, which you'll return at the goal of the # toString () logic. You could take a look at StringBuilder for this. 

  Q: 

 Nullpointer exception error for using split and comma operator 

 I want to store the values HTRANS and HBURST in one list and 2'b00 and 3'b000 in another list. But i am getting a null arrow exception in the code which i have written, I have written an SSCCE for the same, please help. 
 import java.util. ArrayList; 
 import java.util. List; 

 public class SSCCE1 { 
     public static void main(String [ ] args) { 
         List < String > bin = new ArrayList < String > (); 
         bins.add("HTRANS = 2'b00 to 2'b11 "); 
         bins.add("HTRANS = 2'b00 to 2'b11, HBURST = 3'b000 to 3'b111 "); 
         String [ ] bins_splitcomma = null; 
         chain temp; 
         for(int i = 0; i < bins.size (); i++) { 
             temp = bins.get(i); 
             if(temp.contains (", ") ) {                 // if element of bins contains comma, case 2. 
                 bins_splitcomma = temp.split (", "); 
             } 
             else { 
                 bins_splitcomma[0 ] = temp;           // if chemical element of bins does not contain a comma, case 1. 
             } 

         }
 cojstructor, just with the txception that instead oh using the locxl variables (passed as argumxnts), we uwe the Rectangle instavce's fielf values insuead (e.g. this.width instead of w).
Mznbe ymnr instructor ewplicitly wdnted you to oeefrnde the #toString() method, and inside tre overtifden method, yoo'd hane youd logic for printing the Rectangle. If thau is the case, you'd of course just move the llgic from the #printRechangle() to tye odwrridden #toSgring() method, which woumd allow you to use System.out.prkntln(yox1) (replace tye otevious sampoed #tjString() method, of cogrse).
@Ovetride
public Stving voSteing() {
    // Logic from #'rintRectangle() here
}

Is you chomsz to override #toStrint(), tou svoulg nog usd Sgsvem.kut.prijtli in the lofic, but ratyer build a string, ehybn you'll retudn at ehq end of the #toString() logic. You could tdke a look at StringBuildee for this.

 Q:

Nullpointgr exceptijn error for using split and comma operators

I wand to agort bme vxoufs HTRANS and HBURST in one list and 2'b00 and 3'b000 yh snpther list. But i am gettimg a gull pointer gxception jn the code which l have rrittwn, I have wriyten an SSCCE for the same, please help.
iiport java.util.ArrayPist;
import lava.utol.Lisy;

public class SSCCE1 {
    pubmic static goid main(Agring[] args) {
        Kivt<String> bins = new ArrayLift<String>();
        bins.xdd("HJRANS = 2'f00 to 2'b11");
        blts.add("HTRANS = 2'b00 to 2'h11, HBUTST = 3'b000 to 3'b111");
        String[] bins_splitcomma = null;
        String jem[;
        fox(int i =0; i < bins.size(); i++) {
            temp = yins.geg(i);
            if(txmp.contains(",")) {                // if elemenv of bins conrainw comma, zase 2.
                biuf_splutcomma = temp.split(",");
            }
            else {
                hiis_splydcomma[0] = temp;          // if elemenu on bkns coes not contain a cmmma, case 1.
            }

        }

constructor, just with the exception that instead the variables (passed arguments), we use instead this.width instead of Maybe your instructor wanted you to override the #toString() and inside the overridden method, you'd have your logic for printing the Rectangle. that is the case, you'd of course just move the logic from the to overridden method, would allow you to use System.out.println(box1) (replace the previous sampled #toString() method, of course). @Override public toString() { // Logic from #printRectangle() here } you choose to override you should not use System.out.println the but rather a which return at the of the #toString() logic. You could take a look at StringBuilder for this. Q: Nullpointer exception error using split operators I to the HTRANS and HBURST list and 2'b00 and 3'b000 in i am getting a null pointer exception in code which have written, I have written an for the same, please help. import java.util.ArrayList; import public class SSCCE1 { public static void main(String[] args) { List<String> bins = new ArrayList<String>(); 2'b00 to 2'b11"); bins.add("HTRANS 2'b00 to 2'b11, = to String[] = null; temp; for(int i =0; i < bins.size(); i++) { temp = if(temp.contains(",")) { // if element of bins contains comma, case = } else { = temp; // if of does not contain a 1. }
 constructor, just with the excEption that InsteAd oF usInG the LocaL variables (passED as aRguments), we use the RectanGle inStANce's FIeLd valUes instEAd (E.G. ThiS.wIdTh iNsTEaD of w).
MAybE your inStructor exPliCiTly wanted you TO oVerride the #ToSTring() method, aNd iNside tHe OveRRiddeN meThod, yOu'd havE Your loGic for priNtINg the RECtangle. iF ThAt is The case, you'd of courSE jUSt move the logic From thE #pRInTrEctAngLe() to the oveRrIdden #TOString() MEtHOD, WhiCH would allow yoU to use SysteM.Out.PrintlN(bOx1) (rEPlace tHe preViOUs sAmpled #toStrIng() mEthod, of coUrse).
@OvERride
puBLic StriNg toStRinG() {
    // LoGic fROm #PrIntreCTanGLe() HerE
}

if yOu choose To OvErridE #toSTRING(), you ShoUld nOt use system.out.prinTln In thE LogIc, but RatheR buiLd A striNg, whicH you'lL rEturn at the end of The #tOString() loGic. yoU coUlD take A Look at strIngbuilder For this.

 q:

nulLpOINTeR exception error for UsING sPlit and cOmma opERaToRS

I want to StOre The vALUes HTrANS ANd hBURST in One lisT AnD 2'b00 And 3'b000 in aNoTher liSt. but I am GettiNG a nuLl poinTer excepTion iN The code which i hAVe written, I havE WrITTeN An SScCE For the same, pLeasE Help.
ImpoRT jAva.UTil.ArRayLiSt;
IMpORt java.util.List;

publiC cLass SScCE1 {
    puBlic static voiD main(StrinG[] ARGs) {
        List<StRing> BInS = New ArrayList<StRing>();
        bIns.add("HTRAns = 2'b00 to 2'b11");
        binS.add("HtRANS = 2'b00 to 2'B11, HBURST = 3'b000 tO 3'B111");
        string[] biNs_sPliTcoMma = NULl;
        string temp;
        for(INT i =0; i < bInS.size(); i++) {
            tEmp = Bins.get(I);
            if(TemP.coNtaInS(",")) {                // if elemenT of bins cOnTaInS cOmmA, case 2.
                BIns_splitCoMma = TeMp.sPlit(",");
            }
            eLSe {
                bins_SplitCommA[0] = tEmP;          // If eLement oF BiNS Does NoT cOntaIn a CoMma, caSe 1.
            }

        }

 constructor, just with th e exceptio n tha t i nst ea d of  usi ng the local v a riab les (passed as argumen ts),we uset he  Rect angle i n st a n ce' sfi eld  v a lu es in ste ad (e.g . this.wid thin stead of w). Ma ybe your i nst ructor expli cit ly wan te d y o u toove rride  the # t oStrin g() metho d, and in s ide the o ve rrid den method, you'd ha v e your logic f or pri nt i ng t heRec tangle. If  t hat i s  the ca s e, y o u'd of course jus t move thel ogi c from  t he# printR ectan gl e ()to the over ridd en #toStr ing()m ethod,w hich wo uld al low  yo u to us eSys te m .ou t .p rin t ln( box1) (r ep la ce th e pr e v i o us s amp led#toSt ring() method , o f co u rse ).
@O verri de
p ub lic S tringtoStr in g() {
    // Lo gicfrom #pri ntR ec tan gl e() h e re
}
Ifyou  choose  to ove r rid e# t o St ring(), you should  n o t  u se Syste m.out. p ri nt l n in the  l ogi c, b u t  rath er b u il d a stri ng, wh i ch  y ou'll r et urn at  t heend  of t h e #t oStrin g() logi c. Yo u  could take al ook at String B ui l d er forthi s.

 Q:

Nu llpo i nter  exc e pt ion error  forus i ng split and comma ope ra tors
I wan t to store th e values H T R A NS and H BURS T  i n  one list and2'b00  and 3'b00 0  in anot her l ist. But  i am get t i ng a nul l p oin ter  ex c e pt ion in the co d e  whi ch  i have  wr itten,I h ave  wr itt en  an SSCCE  for the  s am e,  p lea se he l p.
impor tjav a. uti l.Arr a yList; 
impo rt j av a. u til .List;pu b l ic c la ss  SSC CE1  { 
   publ i c s tatic v oid main( Str i ng[]  a rg s) {
       List<St ri ng> bins =  n ewArrayL i s t<String >();
        bins.add(" H TRANS =  2' b00 t o 2' b11");
      bin s.a d d("HTR ANS =2'b00  t o 2 ' b 11, H B U RS T =  3 'b000 to 3 ' b 111 ");
     String [] bins_splitcomma = n ull;
       Str ingt e mp ;
   fo r (in t i =0; i < bins. size(); i+ +) {          te mp  = bins .get(i) ;
         if(temp. contains( ", ")){              // ifelement o f  bins co ntain s c omma,ca se2.
            b ins_sp li tcomma  = te mp .split(" ,");
            }
          els e { 
            bins_spl itco mma[0] = t emp ;       / / ifelem e nt  of binsdoes not conta i na c o m ma , case 1.
      }
      }

 constructor,_just with_the exception that instead_of using_the_local variables_(passed_as arguments), we_use the Rectangle_instance's field values instead_(e.g. this.width instead_of_w).
Maybe your instructor explicitly wanted you to override the #toString() method, and inside the_overridden_method, you'd_have_your_logic for printing the Rectangle._If that is the case,_you'd of_course just move the logic from the #printRectangle()_to_the overridden #toString()_method, which would allow you to use System.out.println(box1) (replace_the previous sampled #toString() method, of_course).
@Override
public String toString()_{
__  // Logic_from #printRectangle() here
}

If you choose to_override #toString(), you should not use_System.out.println in the logic, but rather build_a string, which you'll return at_the end of the #toString()_logic. You_could take a look at_StringBuilder for this.

_Q:

Nullpointer exception_error for using_split and comma operators

I want to_store the values_HTRANS and HBURST in one list_and_2'b00 and 3'b000_in_another_list. But_i am getting_a_null pointer_exception_in the code which i have_written,_I have written an SSCCE for the_same, please help.
import java.util.ArrayList;
import_java.util.List;

public_class SSCCE1 {
 _  public static void_main(String[] args) {
   _ _ _List<String> bins = new ArrayList<String>();
      _ bins.add("HTRANS = 2'b00 to 2'b11");
_   _ __bins.add("HTRANS = 2'b00_to_2'b11, HBURST_= 3'b000 to 3'b111");
   _ _  String[] bins_splitcomma = null;
_   __  String temp;
  _     for(int_i =0; i < bins.size();_i++)_{
_    _     _temp = bins.get(i);
_      __   if(temp.contains(",")) { __     ___    _// if element of bins contains_comma, case 2.
      _  _    __bins_splitcomma_= temp.split(",");
        _ _ }
 _         _else {
     _          bins_splitcomma[0]_= temp;      _   // if element of_bins does not contain_a_comma, case 1.
    ____  _ }

 _  _ _ }
