I have a Parameter class which just has parameters
Parameter
{
String inputfilename;
int numA;
double numbB;
etc...
}
and ProcessParameter class that has methods defined
ProcessParameter
{
openParameters
{
//Open file and read the parameters into the Parameter object
BufferedReader openFile = new Buf开发者_开发百科feredReader(new FileReader(parameterFileName));
String[] tokens = openFile.readLine().trim().split(DELIMITER);
Parameter openparameter = new Parameter();
openParameter.setInputFileName(tokens[0]);
openFile.readLine();
openParameter.setNumA = Integer.parseInt(tokens[0]);
}
My Question is : How do I use stack directly on the Parameter Class? *( i have about 15 parameters in the parameter class and will be using Update, save and open methods in the ProcessParameter class)*
I was trying:
Stack<Parameter> stack = new Stack<Parameter>();
stack.push(tokens[0]);
openFile.readLine();
**stack.push(Integer.parseInt(tokens[0]));**
I get this warning: The method push(Parameter) in the type Stack is not applicable for the arguments (int) Would really appreciate any pointers and thanks for the help.
You're trying to push an int
when you said the Stack should contain Parameter
instances.
You'll either need to change the generic type of stack
or change how you store your tokens
.
精彩评论