Note that there are some explanatory texts on larger screens.

plurals
  1. POjava.lang.VerifyError: (class: ea/Individual, method: <init> signature: (I)V) Constructor must call super() or this()
    primarykey
    data
    text
    <p>I am not finding any error in this class, but Netbeans continuously showing red symbol on that class. Class is</p> <pre><code>/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package ea; /** * * @author riyad */ import java.util.Random; import java.util.BitSet; public class Individual { BitSet variable; double x; double fitness; double sharedFitness; final int SIZE; Random generator = new Random(); public Individual(int SIZE) { this.variable = new BitSet(SIZE); this.fitness = 0; this.sharedFitness = 0; this.SIZE = SIZE; for(int i=0; i&lt;SIZE; i++) { if(generator.nextBoolean()) { variable.set(i); } else { variable.clear(i); } } x = Double.parseDouble(variable.toString()); } public Individual copy() { Individual ind = new Individual(SIZE); this.variable = (BitSet) ind.variable.clone(); this.fitness = ind.fitness; this.sharedFitness = ind.sharedFitness; this.x = ind.x; return ind; } public void evaluate() { fitness = x * Math.sin(Math.sqrt(x)); } public boolean getBit(int i) { return variable.get(i); } public BitSet getBitSet() { return variable; } public void setBit(int i) { variable.set(i); } public void clearBit(int i) { variable.clear(i); } public double getFitness() { return fitness; } public double sharedFitness() { return sharedFitness; } public void setSharedFitness(double fitness) { this.sharedFitness = fitness; } public void setFitness(double fitness) { this.fitness = fitness; } } </code></pre> <p>The code is compiling but getting runtime error.</p> <pre><code>Exception in thread "main" java.lang.VerifyError: (class: ea/Individual, method: &lt;init&gt; signature: (I)V) Constructor must call super() or this() </code></pre> <p>In another class, where Individual class is being used:</p> <pre><code>ArrayList&lt;Individual&gt; pop = new ArrayList&lt;Individual&gt;(); </code></pre> <p>This where Individual class is being intantiated:</p> <pre><code>Individual temp = new Individual(STRING_SIZE); pop.add(temp); </code></pre> <p><strong>EDIT</strong></p> <p>I haven't renamed the file manually. All the coding was done in Netbeans. The only problem is when I am creating instance of Individual.</p> <p><strong>EDIT2</strong></p> <p>I have copied the project another place, everything is normal again. probably a bug of Netbeans or JDK</p>
    singulars
    1. This table or related slice is empty.
    plurals
    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