I'm having trouble getting the arraylist length to show in my for loop. I'm a beginner/novice with programming so I might be completely off base here. The output for the ArrayList
is showing up as 0. What I'm trying to do it compare a string from a jTextBox
with an arraylist and see if the String
exists within the List
.
public static void ValidateProtocolCompatiblity(FAS_Define[] faslist, String selectedProtocol, String selectedFAS){
for (int index=0; index < faslist.length;index++){
if (faslist[index].getName() == selectedFAS)
for (int j=0; j < faslist[index].getSupportedProtocol().toArray().length;j++){
fasProtocolList.add(faslist[index].getSupportedProtocol().toString());
}
}
Here is my original array list based on the constructor
FAS_Define[] fasList = new FAS_Define[10];
fasList[0] = new FAS_Define("FAS2552", new ArrayList(Arrays.asList("iSCSI", "FCoE")));
ValidateProtocolCompatiblity(fasList,protocolField, fasField);
Class for the getter/setter/constructor outlining the original array list
public class FAS_Define {
private int id;
private String name;
private List<String> supportedProtocol;
private static int numberofDevice = 0;
public FAS_Define(String cName, ArrayList<String> cSupportedProtocol){
this.name = cName;
this.supportedProtocol = new ArrayList<String>();
numberofDevice++;
id = numberofDevice;
}
public String getName(){return name;}
public void setName(String name){this.name = name;}
public List<String> getSupportedProtocol(){return supportedProtocol;}
public void setSupportedProtocol(List<String> supportedProtocol){this.supportedProtocol = supportedProtocol;}