hi geys ,
I need ow to return a array string to my method
public String[] SearchPort(){
ArrayList<String> arr=new ArrayList<>();
Win32Driver w32Driver= new Win32Driver();
w32Driver.initialize();
port= CommPortIdentifier.getPortIdentifiers();
while(port.hasMoreElements()){
cuport=(CommPortIdentifier) port.nextElement();
if(cuport.getPortType()==CommPortIdentifier.PORT_SERIAL){
// return cuport.getName();
arr.add(cuport.getName());
String[] t=new String[arr.size()];
t=arr.toArray(t);
for(String j:t){
return t;
}
}
//System.out.println(cuport.getName());
}
String h[]={"noo data "};
return h;
}
and this is the main code
SendRecPort sd=new SendRecPort();
String[] result = sd.SearchPort();
for (int i=0; i<result.length; i++) {
jComboBox1.addItem(result[i]);
// jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(result[i]));
}
always retunr one value from search() methode