Hi folks,
I have a chemicals class with various instance variables such as chemical name, boiling point, freeze point etc.
I have created a stream input file with a .csv extension where I want the user to specify a process stream (flow rate, temperature, chemicals inside the stream etc.).
I have the following code in the main method:
Chemicals [] chemObject = new Chemicals[2]; //2 chemicals per stream //If i add this line next: System.out.println(inputStream.next()); it prints the name of the chemical I want chemObject[0] = new Chemicals(inputStream.next()); System.out.println(chemObject[0].getName()); //this prints out null meaning that the chemObject[0] did not get created?
I realized I should have provided more info on the actual Chemicals class and its constructors:
public Chemicals(String name) //Overloaded consutrctor { if (name == "toluene") { this.name = "toluene"; this.boilingPoint=110.6; } } public String getName() { return this.name; }
How do I create an object with a string from an input stream?
Cheers