I had a question regarding this program I was trying to write.
fin = new FileInputStream (args[0]);
BufferedReader d = new BufferedReader(new InputStreamReader(fin));
String str;
while ((str = d.readLine()) != null) {
String [] string = str.split(" ");
System.out.println(string[0]);
int i=0;
if(!(string[0].compareTo("INPUT")==0) || (string[0].compareTo("OUTPUT")==0))
{
// solution goes here
}
}
fin.close();
So the question i have is that i am trying to create objects a1, a2, a3 etc of a class (say A) and then add them as a vertex to a graph. Is there a way to define them dynamically? Would this work?
A [] a;
while(condition is true)
{
a[i].setParameters() // dont worry about this
graph.addVertex(a[i])
i++;
}
If not, can you tell me a better way of doing this? When i try this i get local variable not initialized error. I might be missing something trivial
Note: The project is to design a logic circuit simulator and I am trying to implement a graph styled data structure where nodes depict gates and the interconnects will be edges (I have two classes called gates and interconnects)