Thanks - I think I'm moving in the right direction, but now I'm getting errors when I try to assign the array elements to specific variables. I need to do this so that I can call another reusable class that actually does the math I need. I need that class to recognize the variables.
Please look at my code below. Also, all the code that comes under this is giving errors (it worked before) so I think maybe part of my problem is the brackets - but I can't see it. Please help me.
________________________________________________________________________
public void rfile(){
try{
BufferedReader in = new BufferedReader(new FileReader("c:\\javastuff\\mortgage.txt"));
String line =" ";
int counter = 0;
double[] data = new double[3];
for(int x = 0; x < data.length; x++)
{
data[x] = Double.parseDouble(in.readLine());
if (data[x]=="data0")
{
double loanamt = data[x];
}
else if (data[x]=="data1")
{
double yrsnum = data[x];
}
else if (data[x]=="data2")
{
double rate = data[x];}
}
}
in.close(); //close the reader
}catch (Exception e) {
System.out.println("File Error!");
e.printStackTrace();
}
__________________________________________________________________________
And here are my error messages:
GuiMortgage.java [165:1] 'try' without 'catch' or 'finally'
try{
^
GuiMortgage.java [188:1] illegal start of type
}catch (Exception e) {
^
GuiMortgage.java [192:1] <identifier> expected
themath4array();}
^
GuiMortgage.java [193:1] 'class' or 'interface' expected
double loanamt = data1;
^
GuiMortgage.java [194:1] 'class' or 'interface' expected
double yrsnum = data2;
^
GuiMortgage.java [196:1] 'class' or 'interface' expected
public void themath4array(){}
^
GuiMortgage.java [207:1] 'class' or 'interface' expected
}
^
GuiMortgage.java [210:1] 'class' or 'interface' expected
^
GuiMortgage.java [26:1] GuiMortgage should be declared abstract; it does not define itemStateChanged(java.awt.event.ItemEvent) in GuiMortgage
public class GuiMortgage extends JFrame implements ActionListener, ItemListener {
^
GuiMortgage.java [173:1] operator == cannot be applied to double,java.lang.String
if (data[x]=="data0")
^
GuiMortgage.java [177:1] operator == cannot be applied to double,java.lang.String
else if (data[x]=="data1")
^
GuiMortgage.java [181:1] operator == cannot be applied to double,java.lang.String
else if (data[x]=="data2")
^
GuiMortgage.java [187:1] cannot resolve symbol
symbol : variable in
location: class GuiMortgage
in.close(); //close the reader
^
13 errors
Errors compiling GuiMortgage.