Note that there are some explanatory texts on larger screens.

plurals
  1. POJava Object Instance creation problems
    primarykey
    data
    text
    <p>So I've been struggling all day today trying to create an instance of a class called 'Sport'. I've got my code set up so I run the User Interface, which then runs a constructor, which then runs another constructor which loads the Sport values from a text file.</p> <p>The problem is, the way I'm apparently creating the objects is wrong. Could really use some help.</p> <pre><code>public static void seperateValues(String sportDetail) { String[] sportDetails = sportDetail.split(","); System.out.println("Adding new sport to the Sport collection"); System.out.println(sportDetail); /* for(int i=0; i&lt;sportDetails.length; i++) //just used for testing whether it was splitting correctly { System.out.println(sportDetails[i]); } */ // name,usagefee,insurance,affiliationfees, then court numbers //Tennis,44,10,93,10,11,12,13,14,15,16 int vlength; vlength = sportDetail.length(); String[] sportDetailz; sportDetailz = new String[vlength]; sportDetailz[0] = sportDetails[0]; //name sportDetailz[1] = sportDetails[1]; //usage fees sportDetailz[2] = sportDetails[2]; //insurance sportDetailz[3] = sportDetails[3]; //afflcationfees String vSportObjectName; vSportObjectName = sportDetails[0]; String sportinstance; sportinstance = sportDetails[0]; //this is the name of the sport which I'm hoping each loop around //it will give a new name to Sport sportinstance = new Sport(sportDetails); //System.out.println(Sport.this.name); } </code></pre> <p>Error message: <code>variable sportinstance is already defined in method seperateValues(java.lang.String)</code></p> <p><a href="http://puu.sh/2zil9" rel="nofollow">http://puu.sh/2zil9</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload