I have this Java code
public class SlumbookDriver{
public static void main(String args[]){
Slumbook[] contacts = new Slumbook[19];
autoAdd();
String con1 = contacts[0].viewToString();
System.out.println(con1);
}
with the method autoAdd as something like this
public static void autoAdd(){
contacts[0] = new Slumbook("2014-0002", "Karl Marx", "Karly", "German", "Cologne",
"House", "2358681", "Single", "N/A", "Karl_Marx@yahoo.com");
contacts[1] = new Slumbook("2015-0006", "Fidel Castro", "Strong Man of Cuba", "Cuban",
"Cuba", "Lungon", "7863264", "Married", "Dead", "FidelCatro@msn.com");
}
}
when i try to run it, it says error: Cannot find Symbol
the symbol being variable contacts
the code works properly if i assign the array inside the main, like this:
public class SlumbookDriver{
public static void main(String args[]){
Slumbook[] contacts = new Slumbook[19];
contacts[0] = new Slumbook("2014-0002", "Karl Marx", "Karly", "German", "Cologne",
"House", "2358681", "Single", "N/A", "Karl_Marx@yahoo.com");
contacts[1] = new Slumbook("2015-0006", "Fidel Castro", "Strong Man of Cuba", "Cuban", "Cuba", "Lungon", "7863264", "Married", "Dead", "FidelCatro@msn.com");
String con1 = contacts[0].viewToString();
System.out.println(con1);
}
but that's not what i want