public static int getPort(String serviceName) { 
int PORT = 0; 
while (PORT <= 1023) { 
System.out.println(portServices[PORT]); 
if (serviceName != portServices[PORT]) { 
PORT++; 
} else { 
return PORT; 


while(PORT<=65535){ 
if(serviceName!=portServicesMap.get(PORT)){ 
PORT++; 
}else{ 
return PORT; 


return 0; 

为什么返回的是 
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1024