I'm writing a class that will build a SQL table create statement. what I'd like to do is call a method something like createTable(String tableName ColAndTypes... ct ). When I write the method I don't get any compile errors. I'm having trouble passing the values into the method when I call it though and I think it's because my syntax is wrong and I'm not sure how to fix it. I was wondering if you could look at the example I have provided and let me know what I need to do to fix it. Thanks so much for your help!
import java.util.*;
public class foo
{
public class bar{
public String sBar1, sBar2;
public bar(){
sBar1 = "null";
sBar2 = "null";
}
public bar(String sBar1, String sBar2){
this.sBar1 = sBar1;
this.sBar2 = sBar2;
}
}
String sFoo;
List<bar> bi;
public foo(){
sFoo = "null";
bi = new bar();
}
public foo(Strinf sFoo, bar bi){
this.sFoo = sFoo;
this.bi = bi;
}
public void runFooBar(String sFoo, bar... barArgs)
{
this.sFoo = sFoo;
for(bar x:barArgs){System.out.Println(bi.get(x).sBar1 + ":" + bi.get(x).sBar2);}
}
public static void main(String[] args)
{
foo fi = new foo();
fi.runFooBar("foo 1", ("1 sBar1","1 sBar2"),("2 sBar1 ","2 sBar2"))
}//end main
}//end class
biis aListbut you're initializing it as abar. You have a typoStrinfinstead ofString.List#get(int)expects anint, but you are passing it abar.PascalCase, soBarrather thanbar. To answer your specific question, you don't. We'll not unless you are using Java 8. To solve your current problem pass in instances of your (renamed)Barclass.